1.0.28.38: undefined warning and compilation unit summary tweaking
[sbcl.git] / tests / dynamic-extent.impure.lisp
index aba5a18..99d925a 100644 (file)
     (true v)
     nil))
 
+(defun force-make-array-on-stack (n)
+  (declare (optimize safety))
+  (let ((v (make-array (min n 1))))
+    (declare (sb-int:truly-dynamic-extent v))
+    (true v)
+    nil))
+
 ;;; MAKE-STRUCTURE
 
 (declaim (inline make-fp-struct-1))
   (assert-no-consing (dx-value-cell 13))
   (assert-no-consing (cons-on-stack 42))
   (assert-no-consing (make-array-on-stack))
+  (assert-no-consing (force-make-array-on-stack 128))
   (assert-no-consing (make-foo1-on-stack 123))
   (assert-no-consing (nested-good 42))
   (#+raw-instance-init-vops assert-no-consing
     (array-total-size array)))
 (with-test (:name :length-and-words-packed-in-same-tn)
   (assert (= 1 (length-and-words-packed-in-same-tn -3))))
+
+(with-test (:name :handler-case-bogus-compiler-note)
+  (handler-bind ((compiler-note #'error))
+    ;; Taken from SWANK, used to signal a bogus stack allocation
+    ;; failure note.
+    (compile nil
+             `(lambda (files fasl-dir load)
+                (let ((needs-recompile nil))
+                  (dolist (src files)
+                    (let ((dest (binary-pathname src fasl-dir)))
+                      (handler-case
+                          (progn
+                            (when (or needs-recompile
+                                      (not (probe-file dest))
+                                      (file-newer-p src dest))
+                              (setq needs-recompile t)
+                              (ensure-directories-exist dest)
+                              (compile-file src :output-file dest :print nil :verbose t))
+                            (when load
+                              (load dest :verbose t)))
+                        (serious-condition (c)
+                          (handle-loadtime-error c dest))))))))))
+
+(with-test (:name :dx-compiler-notes)
+  (let ((n 0))
+    (handler-bind ((compiler-note (lambda (c)
+                                    (declare (ignore cc))
+                                    (incf n))))
+      (compile nil `(lambda (x)
+                      (let ((v (make-array x)))
+                        (declare (dynamic-extent v))
+                        (length v))))
+      (assert (= 1 n))
+      (compile nil `(lambda (x)
+                      (let ((y (if (plusp x)
+                                   (true x)
+                                   (true (- x)))))
+                        (declare (dynamic-extent y))
+                        (print y)
+                        nil)))
+      (assert (= 3 n)))))
 \f