More refactoring around COMPILER-WARN
... new src/code/cross-condition file to house cross-compiler
definitions of conditions
... new condition types for format warnings
... (note that this separation between xc and target definitions
allows us to make warnings of different severity
during cross-compilation easily)
* Some work on conditions emitted by the system
** eliminated COMPILER-WARN and COMPILER-STYLE-WARN, which
were simply limited versions of WARN and STYLE-WARN.
* Some work on conditions emitted by the system
** eliminated COMPILER-WARN and COMPILER-STYLE-WARN, which
were simply limited versions of WARN and STYLE-WARN.
+ ** made STYLE-WARN parallel WARN more closely (by accepting
+ a condition type, which should be a subtype of
+ STYLE-WARNING, and initargs, as well as a format
+ string and format arguments for SIMPLE-STYLE-WARNING.
+ (WARN can also be used to signal STYLE-WARNINGs, but
+ STYLE-WARN helps to document the code)
** eliminated use of INHIBIT-WARNINGS by code emitted by the
system from user code.
** caused use of INHIBIT-WARNINGS to signal a STYLE-WARNING.
** eliminated use of INHIBIT-WARNINGS by code emitted by the
system from user code.
** caused use of INHIBIT-WARNINGS to signal a STYLE-WARNING.
("src/code/cross-sap" :not-target)
("src/code/cross-thread" :not-target)
("src/code/cross-make-load-form" :not-target)
("src/code/cross-sap" :not-target)
("src/code/cross-thread" :not-target)
("src/code/cross-make-load-form" :not-target)
+ ("src/code/cross-condition" :not-target)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; stuff needed early both in cross-compilation host and in target Lisp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; stuff needed early both in cross-compilation host and in target Lisp
"DUPLICATE-DEFINITION" "DUPLICATE-DEFINITION-NAME"
"PACKAGE-AT-VARIANCE" "ARRAY-INITIAL-ELEMENT-MISMATCH"
"TYPE-WARNING" "LOCAL-ARGUMENT-MISMATCH"
"DUPLICATE-DEFINITION" "DUPLICATE-DEFINITION-NAME"
"PACKAGE-AT-VARIANCE" "ARRAY-INITIAL-ELEMENT-MISMATCH"
"TYPE-WARNING" "LOCAL-ARGUMENT-MISMATCH"
+ "FORMAT-ARGS-MISMATCH" "FORMAT-TOO-FEW-ARGS-WARNING"
+ "FORMAT-TOO-MANY-ARGS-WARNING"
+
;; ..and DEFTYPEs..
"INDEX" "LOAD/STORE-INDEX"
"SIGNED-BYTE-WITH-A-BITE-OUT"
;; ..and DEFTYPEs..
"INDEX" "LOAD/STORE-INDEX"
"SIGNED-BYTE-WITH-A-BITE-OUT"
;;;; setup of CONDITION machinery, only because that makes it easier to
;;;; get cold init to work.
;;;; setup of CONDITION machinery, only because that makes it easier to
;;;; get cold init to work.
+(define-condition simple-style-warning (simple-condition style-warning) ())
+
(define-condition values-type-error (type-error)
()
(:report
(define-condition values-type-error (type-error)
()
(:report
(define-condition local-argument-mismatch (reference-condition simple-warning)
()
(:default-initargs :references (list '(:ansi-cl :section (3 2 2 3)))))
(define-condition local-argument-mismatch (reference-condition simple-warning)
()
(:default-initargs :references (list '(:ansi-cl :section (3 2 2 3)))))
+
+(define-condition format-args-mismatch (reference-condition)
+ ()
+ (:default-initargs :references (list '(:ansi-cl :section (22 3 10 2)))))
+
+(define-condition format-too-few-args-warning
+ (format-args-mismatch simple-warning)
+ ())
+(define-condition format-too-many-args-warning
+ (format-args-mismatch simple-style-warning)
+ ())
\f
;;;; restart definitions
\f
;;;; restart definitions
-(define-condition simple-style-warning (simple-condition style-warning) ())
-
;;; not sure this is the right place, but where else?
(defun style-warn (format-control &rest format-arguments)
(/show0 "entering STYLE-WARN")
;;; not sure this is the right place, but where else?
(defun style-warn (format-control &rest format-arguments)
(/show0 "entering STYLE-WARN")
;;; for compile-time argument count checking.
;;;
;;; for compile-time argument count checking.
;;;
-;;; FIXME I: this is currently called from DEFTRANSFORMs, the vast
-;;; majority of which are not going to transform the code, but instead
-;;; are going to GIVE-UP-IR1-TRANSFORM unconditionally. It would be
-;;; nice to make this explicit, maybe by implementing a new
-;;; "optimizer" (say, DEFOPTIMIZER CONSISTENCY-CHECK).
-;;;
;;; FIXME II: In some cases, type information could be correlated; for
;;; instance, ~{ ... ~} requires a list argument, so if the lvar-type
;;; of a corresponding argument is known and does not intersect the
;;; FIXME II: In some cases, type information could be correlated; for
;;; instance, ~{ ... ~} requires a list argument, so if the lvar-type
;;; of a corresponding argument is known and does not intersect the
(let ((nargs (length args)))
(cond
((< nargs min)
(let ((nargs (length args)))
(cond
((< nargs min)
- (compiler-warn "Too few arguments (~D) to ~S ~S: ~
- requires at least ~D."
- nargs fun string min))
+ (warn 'format-too-few-args-warning
+ :format-control
+ "Too few arguments (~D) to ~S ~S: requires at least ~D."
+ :format-arguments (list nargs fun string min)))
- (;; to get warned about probably bogus code at
- ;; cross-compile time.
- #+sb-xc-host compiler-warn
- ;; ANSI saith that too many arguments doesn't cause a
- ;; run-time error.
- #-sb-xc-host compiler-style-warn
- "Too many arguments (~D) to ~S ~S: uses at most ~D."
- nargs fun string max)))))))
+ (warn 'format-too-many-args-warning
+ :format-control
+ "Too many arguments (~D) to ~S ~S: uses at most ~D."
+ :format-arguments (list nargs fun string max))))))))
(defoptimizer (format optimizer) ((dest control &rest args))
(when (constant-lvar-p control)
(defoptimizer (format optimizer) ((dest control &rest args))
(when (constant-lvar-p control)
(let ((nargs (length args)))
(cond
((< nargs (min min1 min2))
(let ((nargs (length args)))
(cond
((< nargs (min min1 min2))
- (compiler-warn "Too few arguments (~D) to ~S ~S ~S: ~
- requires at least ~D."
- nargs 'cerror y x (min min1 min2)))
+ (warn 'format-too-few-args-warning
+ :format-control
+ "Too few arguments (~D) to ~S ~S ~S: ~
+ requires at least ~D."
+ :format-arguments
+ (list nargs 'cerror y x (min min1 min2))))
((> nargs (max max1 max2))
((> nargs (max max1 max2))
- (;; to get warned about probably bogus code at
- ;; cross-compile time.
- #+sb-xc-host compiler-warn
- ;; ANSI saith that too many arguments doesn't cause a
- ;; run-time error.
- #-sb-xc-host compiler-style-warn
- "Too many arguments (~D) to ~S ~S ~S: uses at most ~D."
- nargs 'cerror y x (max max1 max2)))))))))))))
+ (warn 'format-too-many-args-warning
+ :format-control
+ "Too many arguments (~D) to ~S ~S ~S: ~
+ uses at most ~D."
+ :format-arguments
+ (list nargs 'cerror y x (max max1 max2))))))))))))))
(defoptimizer (coerce derive-type) ((value type))
(cond
(defoptimizer (coerce derive-type) ((value type))
(cond
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)