0.9.4.74:
[sbcl.git] / tests / compiler.test.sh
index de4512d..25c208c 100644 (file)
@@ -286,6 +286,12 @@ cat > $tmpfilename <<EOF
 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.
@@ -295,6 +301,49 @@ cat > $tmpfilename <<EOF
 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
+
 rm $tmpfilename
 rm $compiled_tmpfilename