# While most of SBCL is derived from the CMU CL system, the test
# files (like this one) were written from scratch after the fork
# from CMU CL.
-#
+#
# This software is in the public domain and is provided with
# absolutely no warranty. See the COPYING and CREDITS files for
# more information.
# having the same name.
cat > $tmpfilename <<EOF
(in-package :cl-user)
- (defun foo (x)
+ (defun foo (x)
(flet ((baz (y) (load y)))
(declare (notinline baz))
(baz x)))
- (defun bar (x)
+ (defun bar (x)
(flet ((baz (y) (load y)))
(declare (notinline baz))
(baz x)))
cat > $tmpfilename <<EOF
(in-package :cl-user)
(defun foo (x) (list x))
- (defun bar (x)
+ (defun bar (x)
(declare (notinline foo))
(1+ (foo x)))
EOF
# been there
cat > $tmpfilename <<EOF
(eval-when (:compile-toplevel :load-toplevel :execute)
- (defstruct buffer-state
+ (defstruct buffer-state
(output-index 0)))
-
+
(defclass buffered-stream-mixin ()
((buffer-state :initform (make-buffer-state))))
-
+
(defgeneric frob (stream))
(defmethod frob ((stream t))
nil)
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.
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
+(declaim (optimize (speed 3) (space 0) (safety 0)))
+
+(defun foo (bar)
+ (last bar))
+EOF
+expect_clean_compile $tmpfilename
+
rm $tmpfilename
rm $compiled_tmpfilename
-# success
+# success
exit 104