0.8.11.4:
[sbcl.git] / tests / compiler.test.sh
index fd948bf..0a4624c 100644 (file)
@@ -50,6 +50,23 @@ cat > $tmpfilename <<EOF
 EOF
 expect_clean_compile $tmpfilename
 
+# This shouldn't fail because it's not really a multiple definition
+cat > $tmpfilename <<EOF
+    (in-package :cl-user)
+    (eval-when (:compile-toplevel :load-toplevel :execute)
+      (defun foo (x) x))
+EOF
+expect_clean_compile $tmpfilename
+
+# Likewise
+cat > $tmpfilename <<EOF
+    (in-package :cl-user)
+    (eval-when (:compile-toplevel)
+      (defun foo (x) x))
+    (defun foo (x) x)
+EOF
+expect_clean_compile $tmpfilename
+
 # This shouldn't fail despite the apparent type mismatch, because of
 # the NOTINLINE declamation.
 cat > $tmpfilename <<EOF
@@ -60,6 +77,17 @@ cat > $tmpfilename <<EOF
 EOF
 expect_clean_compile $tmpfilename
 
+# This shouldn't fail, but did until sbcl-0.8.10.4x
+cat > $tmpfilename <<EOF
+    (in-package :cl-user)
+    (declaim (inline foo))
+    (defun foo (x)
+      (1+ x))
+    (defun bar (y)
+      (list (foo y) (if (> y 1) (funcall (if (> y 0) #'foo #'identity) y))))
+EOF
+expect_clean_compile $tmpfilename
+
 # This shouldn't fail despite the apparent type mismatch, because of
 # the NOTINLINE declaration.
 cat > $tmpfilename <<EOF
@@ -151,6 +179,88 @@ cat > $tmpfilename <<EOF
 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