X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.pure.lisp;h=948d419bbc8d7b2d882a2efda56e893b4d0da6e4;hb=2b596efa9a6b08a22bbdcdf88198c5d2af1d0335;hp=30cc9dcf851d272b94bba2722b8d909ee0ca8c43;hpb=3cf5c8351289d390112a3842b6c03e17cee20211;p=sbcl.git diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index 30cc9dc..948d419 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -446,8 +446,8 @@ (declare (notinline mapcar)) (1+ (mapcar #'print '(1 2 3))))))) -;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant -;; index was effectless +;;; bug found by Paul Dietz: (SETF AREF) for bit vectors with constant +;;; index was effectless (let ((f (compile nil '(lambda (a v) (declare (type simple-bit-vector a) (type bit v)) (declare (optimize (speed 3) (safety 0))) @@ -457,3 +457,66 @@ (assert (equal y #*00)) (funcall f y 1) (assert (equal y #*10)))) + +(handler-bind ((sb-ext:compiler-note #'error)) + (compile nil '(lambda (x) + (declare (type (simple-array (simple-string 3) (5)) x)) + (aref (aref x 0) 0)))) + +;;; compiler failure +(let ((f (compile nil '(lambda (x) (typep x '(not (member 0d0))))))) + (assert (funcall f 1d0))) + +(compile nil '(lambda (x) + (declare (double-float x)) + (let ((y (* x pi))) + (atan y y)))) + +;;; bogus optimization of BIT-NOT +(multiple-value-bind (result x) + (eval '(let ((x (eval #*1001))) + (declare (optimize (speed 2) (space 3)) + (type (bit-vector) x)) + (values (bit-not x nil) x))) + (assert (equal x #*1001)) + (assert (equal result #*0110))) + +;;; the VECTOR type in CONCATENATE/MERGE/MAKE-SEQUENCE means (VECTOR T). +(handler-bind ((sb-ext:compiler-note #'error)) + (assert (equalp (funcall + (compile + nil + '(lambda () + (let ((x (make-sequence 'vector 10 :initial-element 'a))) + (setf (aref x 4) 'b) + x)))) + #(a a a a b a a a a a)))) + +;;; this is not a check for a bug, but rather a test of compiler +;;; quality +(dolist (type '((integer 0 *) ; upper bound + (real (-1) *) + float ; class + (real * (-10)) ; lower bound + )) + (assert (nth-value + 1 (compile nil + `(lambda (n) + (declare (optimize (speed 3) (compilation-speed 0))) + (loop for i from 1 to (the (integer -17 10) n) by 2 + collect (when (> (random 10) 5) + (the ,type (- i 11))))))))) + +;;; bug 278b +;;; +;;; We suppose that INTEGER arithmetic cannot be efficient, and the +;;; compiler has an optimized VOP for +; so this code should cause an +;;; efficiency note. +(assert (eq (block nil + (handler-case + (compile nil '(lambda (i) + (declare (optimize speed)) + (declare (type integer i)) + (+ i 2))) + (sb-ext:compiler-note (c) (return :good)))) + :good))