+# MUFFLE-CONDITIONS tests
+cat > $tmpfilename <<EOF
+ (defun foo ()
+ (declare (muffle-conditions style-warning))
+ (bar))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+ (defun foo ()
+ (declare (muffle-conditions code-deletion-note))
+ (if t (foo) (foo)))
+EOF
+fail_on_compiler_note $tmpfilename
+
+cat > $tmpfilename <<EOF
+ (defun foo (x y)
+ (declare (muffle-conditions compiler-note))
+ (declare (optimize speed))
+ (+ x y))
+EOF
+fail_on_compiler_note $tmpfilename
+
+cat > $tmpfilename <<EOF
+ (declaim (muffle-conditions compiler-note))
+ (defun foo (x y)
+ (declare (optimize speed))
+ (+ x y))
+EOF
+fail_on_compiler_note $tmpfilename
+
+cat > $tmpfilename <<EOF
+ (declaim (muffle-conditions compiler-note))
+ (defun foo (x y)
+ (declare (unmuffle-conditions compiler-note))
+ (declare (optimize speed))
+ (+ x y))
+EOF
+expect_compiler_note $tmpfilename
+
+# undefined variable causes a WARNING
+cat > $tmpfilename <<EOF
+ (declaim (muffle-conditions warning))
+ (declaim (unmuffle-conditions style-warning))
+ (defun foo () x)
+EOF
+expect_clean_compile $tmpfilename
+
+# top level LOCALLY behaves nicely
+cat > $tmpfilename <<EOF
+ (locally
+ (declare (muffle-conditions warning))
+ (defun foo () x))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+ (locally
+ (declare (muffle-conditions warning))
+ (defun foo () x))
+ (defun bar () x)
+EOF
+expect_failed_compile $tmpfilename
+
+# This should fail, and fail nicely -- not eg. loop trying to dump
+# references to the unbound variable.
+cat > $tmpfilename <<EOF
+(defmacro macro-with-unbound-variables (foo)
+ \`(print ,bar))
+
+(macro-with-unbound-variables 'xxx)
+EOF
+expect_failed_compile $tmpfilename
+
+# This should fail, as the MAKE-LOAD-FORM must be used for
+# externalizing conditions, and the method for CONDITION must signal
+# an error.
+cat > $tmpfilename <<EOF
+(defvar *oops* #.(make-condition 'condition))
+EOF
+expect_failed_compile $tmpfilename
+
+# This should fail, as the MAKE-LOAD-FORM must be used for objects,
+# and the method for STANDARD.OBJECT is required to signal an error.
+cat > $tmpfilename <<EOF
+(defvar *oops* #.(make-instance 'standard-object))
+EOF
+expect_failed_compile $tmpfilename
+
+# This should be clean
+cat > $tmpfilename <<EOF
+(defvar *string* (make-string 10 :element-type 'base-char))
+EOF
+expect_clean_compile $tmpfilename
+
+# This should style-warn (but not warn or otherwise fail) as the call
+# to FORMAT has too many arguments, which is bad style but not
+# otherwise fatal.
+cat > $tmpfilename <<EOF
+(defun foo (a b)
+ (format nil "abc~~def" a b))
+EOF
+expect_warned_compile $tmpfilename
+
+# Tests that destructive-functions on known-constant data cause
+# compile-time warnings.
+cat > $tmpfilename <<EOF
+(let ((string "foo"))
+ (defun foo ()
+ (setf string "bar")))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun foo ()
+ (let (result)
+ (nreverse result)))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun bar ()
+ (let ((result ""))
+ (nreverse result)))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(let ((string "foo"))
+ (defun foo ()
+ (replace string "bar")))
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun foo ()
+ (setf (char "bar" 0) #\1))
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(let ((foo '(1 2 3)))
+ (defun foo ()
+ (nconc foo foo)))
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+x
+y
+z
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(declaim (optimize (speed 3) (space 0) (safety 0)))
+
+(defun foo (bar)
+ (last bar))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defstruct foo
+ (bar #p"/tmp/"))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (defstruct foox)
+ (defmethod make-load-form ((foo foox) &optional env)
+ (declare (ignore env))
+ '(make-foox)))
+(defstruct bar
+ (foo #.(make-foox)))
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defun something (x) x)
+...
+(defun something-more (x) x)
+EOF
+expect_aborted_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+(if t (locally))
+EOF
+expect_clean_cload $tmpfilename
+
+cat > $tmpfilename <<EOF
+(defconstant cl-package (find-package :cl))
+(defun cl-symbol-p (x)
+ (eq (symbol-package x) cl-package))
+EOF
+expect_clean_cload $tmpfilename