* 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.
;;;; 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 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
;;; 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
(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)))
((> nargs max)
- (;; 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)
(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))
- (;; 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