Tolerate non-simple strings when checking arguments to CERROR.
[sbcl.git] / src / code / cross-condition.lisp
blobbe69bef6a152f6ae7697f730b1185c33c4a830e8
1 ;;;; cross-compiler-only versions of conditions
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!KERNEL")
14 (define-condition simple-style-warning (simple-condition style-warning) ())
15 (defun style-warn (datum &rest arguments)
16 ;; Cross-compiler needs a special-case for DATUM being a string,
17 ;; because it needs to produce a SIMPLE-STYLE-WARNING, not SIMPLE-WARNING.
18 ;; The SBCL-specific %WARN function - which allows specifying the default
19 ;; condition class when handed a string - exists only on the target lisp.
20 (if (stringp datum)
21 (warn 'simple-style-warning
22 :format-control datum :format-arguments arguments)
23 (apply #'warn datum arguments)))
25 (define-condition format-too-few-args-warning (simple-warning) ())
26 ;;; in the cross-compiler, this is a full warning. In the target
27 ;;; compiler, it will only be a style-warning.
28 (define-condition format-too-many-args-warning (simple-warning) ())
30 ;;; KLUDGE: OAOOM warning: see condition.lisp -- we want a full
31 ;;; definition in the cross-compiler as well, in order to have nice
32 ;;; error messages instead of complaints of undefined-function
33 ;;; ENCAPSULATED-CONDITION.
34 (define-condition encapsulated-condition (condition)
35 ((condition :initarg :condition :reader encapsulated-condition)))
37 ;;; KLUDGE: another OAOOM problem, this time to allow conditions with
38 ;;; REFERENCE-CONDITION in their supercondition list on the host.
39 ;;; (This doesn't feel like the entirely right solution, it has to be
40 ;;; said.) -- CSR, 2004-09-15
41 (define-condition reference-condition ()
42 ((references :initarg :references :reader reference-condition-references)))
44 ;;; KLUDGE: yet another OAOOM.
45 ;;;
46 ;;; FIXME: This is clearly one OAOOM KLUDGE too many in a row. When tempted
47 ;;; to add another one invent DEF!CONDITION or whatever seems necessary,
48 ;;; and replace these.
49 (define-condition type-warning (reference-condition simple-warning)
51 (:default-initargs :references '((:sbcl :node "Handling of Types"))))
52 (define-condition type-style-warning (reference-condition simple-style-warning)
54 (:default-initargs :references '((:sbcl :node "Handling of Types"))))
56 (define-condition bug (simple-error)
58 (:report
59 (lambda (condition stream)
60 (format stream
61 "~@< ~? ~:@_~?~:>"
62 (simple-condition-format-control condition)
63 (simple-condition-format-arguments condition)
64 "~@<If you see this and are an SBCL ~
65 developer, then it is probable that you have made a change to the ~
66 system that has broken the ability for SBCL to compile, usually by ~
67 removing an assumed invariant of the system, but sometimes by making ~
68 an averrance that is violated (check your code!). If you are a user, ~
69 please submit a bug report to the developers' mailing list, details of ~
70 which can be found at <http://sbcl.sourceforge.net/>.~:@>"
71 ()))))
73 ;;; OAOOM...
74 (define-condition compiler-macro-keyword-problem ()
75 ((argument :initarg :argument :reader compiler-macro-keyword-argument))
76 (:report (lambda (condition stream)
77 (format stream "~@<Argument ~S in keyword position is not ~
78 a self-evaluating symbol, preventing compiler-macro ~
79 expansion.~@:>"
80 (compiler-macro-keyword-argument condition)))))
82 ;;; OAOOM...
83 (define-condition duplicate-definition (reference-condition warning)
84 ((name :initarg :name :reader duplicate-definition-name))
85 (:report (lambda (c s)
86 (format s "~@<Duplicate definition for ~S found in ~
87 one file.~@:>"
88 (duplicate-definition-name c))))
89 (:default-initargs :references '((:ansi-cl :section (3 2 2 3)))))
91 ;;; These should never be instantiated before the real definitions
92 ;;; come in.
93 (deftype package-lock-violation () nil)
94 (deftype package-locked-error () nil)
95 (deftype symbol-package-locked-error () nil)
97 (define-condition sb!c:inlining-dependency-failure
98 ;; By inheriting from WARNING, not STYLE-WARNING,
99 ;; we hold ourselves to a higher standard.
100 (simple-warning) ())