0.8.10.29:
[sbcl.git] / tests / compiler.test.sh
index 264f474..b7f34a1 100644 (file)
@@ -130,6 +130,109 @@ cat > $tmpfilename <<EOF
 EOF
 fail_on_compiler_note $tmpfilename
 
+# test case from Rudi for some CLOS WARNINGness that shouldn't have
+# been there
+cat > $tmpfilename <<EOF
+    (eval-when (:compile-toplevel :load-toplevel :execute)
+      (defstruct buffer-state 
+        (output-index 0)))
+    
+    (defclass buffered-stream-mixin ()
+      ((buffer-state :initform (make-buffer-state))))
+    
+    (defgeneric frob (stream))
+    (defmethod frob ((stream t))
+      nil)
+    (defmethod frob ((stream buffered-stream-mixin))
+      (symbol-macrolet
+            ((index (buffer-state-output-index (slot-value stream 'buffer-state))))
+          (setf index 0))
+      (call-next-method))
+EOF
+expect_clean_compile $tmpfilename
+
+# undeclared unbound variables should cause a full warning, as they
+# invoke undefined behaviour
+cat > $tmpfilename <<EOF
+    (defun foo () x)
+EOF
+expect_failed_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+    (declaim (special *x*))
+    (defun foo () *x*)
+EOF
+expect_clean_compile $tmpfilename
+
+cat > $tmpfilename <<EOF
+    (defun foo () (declare (special x)) x)
+EOF
+expect_clean_compile $tmpfilename
+
+# 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
+
 rm $tmpfilename
 rm $compiled_tmpfilename