Initial revision
[sbcl.git] / src / compiler / compiler-error.lisp
1 ;;;; the bare essentials of compiler error handling (FIXME: to be
2 ;;;; moved to early-c.lisp when stable)
3
4 ;;;; This software is part of the SBCL system. See the README file for
5 ;;;; more information.
6 ;;;;
7 ;;;; This software is derived from the CMU CL system, which was
8 ;;;; written at Carnegie Mellon University and released into the
9 ;;;; public domain. The software is in the public domain and is
10 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
11 ;;;; files for more information.
12
13 (in-package "SB!C")
14
15 (file-comment
16   "$Header$")
17
18 ;;; a function that is called to unwind out of COMPILER-ERROR
19 (declaim (type (function () nil) *compiler-error-bailout*))
20 (defvar *compiler-error-bailout*
21   (lambda () (error "COMPILER-ERROR with no bailout")))
22
23 ;;; We have a separate COMPILER-ERROR condition to allow us to
24 ;;; distinguish internal compiler errors from user errors.
25 ;;; Non-compiler errors put us in the debugger.
26 (define-condition compiler-error (simple-error) ())
27
28 ;;; Signal the appropriate condition. COMPILER-ERROR calls the bailout
29 ;;; function so that it never returns (but compilation continues).
30 ;;; COMPILER-ABORT falls through to the default error handling, so
31 ;;; compilation terminates. 
32 (declaim (ftype (function (string &rest t) nil) compiler-error compiler-abort))
33 (declaim (ftype (function (string &rest t) (values))
34                 compiler-warning compiler-style-warning))
35 (defun compiler-abort (format-string &rest format-args)
36   (error 'compiler-error
37          :format-control format-string
38          :format-arguments format-args))
39 (defun compiler-error (format-string &rest format-args)
40   (cerror "Replace form with call to ERROR."
41           'compiler-error
42           :format-control format-string
43           :format-arguments format-args)
44   (funcall *compiler-error-bailout*)
45   ;; FIXME: It might be nice to define a BUG or OOPS function for "shouldn't
46   ;; happen" cases like this.
47   (error "internal error, control returned from *COMPILER-ERROR-BAILOUT*"))
48 (defun compiler-warning (format-string &rest format-args)
49   (apply #'warn format-string format-args)
50   (values))
51 (defun compiler-style-warning (format-string &rest format-args)
52   (apply #'style-warn format-string format-args)
53   (values))