3 # This software is part of the SBCL system. See the README file for
6 # While most of SBCL is derived from the CMU CL system, the test
7 # files (like this one) were written from scratch after the fork
10 # This software is in the public domain and is provided with
11 # absolutely no warranty. See the COPYING and CREDITS files for
16 base_tmpfilename
="compiler-test-$$-tmp"
17 tmpfilename
="$base_tmpfilename.lisp"
18 compiled_tmpfilename
="$base_tmpfilename.fasl"
20 # This should fail, as type inference should show that the call to FOO
21 # will return something of the wrong type.
22 cat > $tmpfilename <<EOF
24 (defun foo (x) (list x))
25 (defun bar (x) (1+ (foo x)))
27 expect_failed_compile
$tmpfilename
29 # This should fail, as we define a function multiply in the same file
31 cat > $tmpfilename <<EOF
33 (defun foo (x) (list x))
34 (defun foo (x) (cons x x))
36 expect_failed_compile
$tmpfilename
38 # This shouldn't fail, as the inner FLETs should not be treated as
39 # having the same name.
40 cat > $tmpfilename <<EOF
43 (flet ((baz (y) (load y)))
44 (declare (notinline baz))
47 (flet ((baz (y) (load y)))
48 (declare (notinline baz))
51 expect_clean_compile
$tmpfilename
53 # This shouldn't fail despite the apparent type mismatch, because of
54 # the NOTINLINE declamation.
55 cat > $tmpfilename <<EOF
57 (defun foo (x) (list x))
58 (declaim (notinline foo))
59 (defun bar (x) (1+ (foo x)))
61 expect_clean_compile
$tmpfilename
63 # This shouldn't fail despite the apparent type mismatch, because of
64 # the NOTINLINE declaration.
65 cat > $tmpfilename <<EOF
67 (defun foo (x) (list x))
69 (declare (notinline foo))
72 expect_clean_compile
$tmpfilename
74 # This in an ideal world would fail (that is, return with FAILURE-P
75 # set), but at present it doesn't.
76 cat > $tmpfilename <<EOF
78 (defun foo (x) (list x))
80 (declare (notinline foo))
82 (declare (inline foo))
85 # expect_failed_compile $tmpfilename
87 # This used to not warn, because the VALUES derive-type optimizer was
88 # insufficiently precise.
89 cat > $tmpfilename <<EOF
91 (defun foo (x) (declare (ignore x)) (values))
92 (defun bar (x) (1+ (foo x)))
94 expect_failed_compile
$tmpfilename
96 # Even after making the VALUES derive-type optimizer more precise, the
97 # following should still be clean.
98 cat > $tmpfilename <<EOF
100 (defun foo (x) (declare (ignore x)) (values))
101 (defun bar (x) (car x))
103 expect_clean_compile
$tmpfilename
105 # NOTINLINE on known functions shouldn't inhibit type inference
106 # (spotted by APD sbcl-devel 2003-06-14)
107 cat > $tmpfilename <<EOF
108 (in-package :cl-user)
110 (declare (notinline list))
113 expect_failed_compile
$tmpfilename
115 # ERROR wants to check its format string for sanity...
116 cat > $tmpfilename <<EOF
117 (in-package :cl-user)
122 expect_failed_compile
$tmpfilename
124 # ... but it (ERROR) shouldn't complain about being unable to optimize
125 # when it's uncertain about its argument's type
126 cat > $tmpfilename <<EOF
127 (in-package :cl-user)
131 fail_on_compiler_note
$tmpfilename
134 rm $compiled_tmpfilename