X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler.impure-cload.lisp;h=41d052513b935905990dc854308db9c105ac50c7;hb=7c7e6276719b8d40fddec2070cad81064a25c8ed;hp=956c43ca374701bb0752cc83112b6e4155620b25;hpb=d42759291677be7634fb2fd86562d746f97a7a53;p=sbcl.git diff --git a/tests/compiler.impure-cload.lisp b/tests/compiler.impure-cload.lisp index 956c43c..41d0525 100644 --- a/tests/compiler.impure-cload.lisp +++ b/tests/compiler.impure-cload.lisp @@ -377,8 +377,70 @@ ;;; bug 313: source transforms were "lisp-1" (defun srctran-lisp1-1 (cadr) (if (functionp cadr) (funcall cadr 1) nil)) (assert (eql (funcall (eval #'srctran-lisp1-1) #'identity) 1)) -(defvar caar) +(without-package-locks + ;; this be a nasal demon, but test anyways + (defvar caar)) (defun srctran-lisp1-2 (caar) (funcall (sb-ext:truly-the function caar) 1)) (assert (eql (funcall (eval #'srctran-lisp1-2) #'identity) 1)) + +;;; partial bug 262: reference of deleted CTRAN (in RETURN-FROM) +;;; during inline expansion. Bug report by Peter Denno, simplified +;;; test case by David Wragg. +(defun bug262-return-from (x &aux (y nil)) + (labels ((foo-a (z) (return-from bug262-return-from z)) + (foo-b (z) (foo-a z))) + (declare (inline foo-a)) + (foo-a x))) + +;;; broken inference of an upper bound of an iteration variable, +;;; reported by Rajat Datta. +(defun isieve (num) + (let ((vec (make-array num :initial-element 0)) + (acc 0)) + (do ((i 2 (+ i 1))) + ((>= i num) 'done) + (when (= (svref vec i) 0) + (do ((j (* i i) (+ j i))) + ((>= j num) 'done) + (setf (svref vec j) 1)) + (incf acc))) + acc)) + +(assert (= (isieve 46349) 4792)) + +;;; COERCE should not be constant-folded (reported by Nikodemus +;;; Siivola) +(let ((f (gensym))) + (setf (fdefinition f) (lambda (x) x)) + (let ((g (compile nil `(lambda () (coerce ',f 'function))))) + (setf (fdefinition f) (lambda (x) (1+ x))) + (assert (eq (funcall g) (fdefinition f))))) + +(let ((x (coerce '(1 11) 'vector))) + (incf (aref x 0)) + (assert (equalp x #(2 11)))) + +;;; and BIT-* too (reported by Paul F. Dietz) +(loop with v1 = #*0011 + and v2 = #*0101 + for f in '(bit-and bit-andc1 bit-andc2 bit-eqv + bit-ior bit-nand bit-nor bit-not + bit-orc1 bit-orc2 bit-xor + ) + for form = `(lambda () + (let ((v (,f ,v1 ,v2))) + (setf (aref v 0) (- 1 (aref v 0))) + (aref v 0))) + for compiled-res = (funcall (compile nil form)) + for real-res = (- 1 (aref (funcall f v1 v2) 0)) + do (assert (equal compiled-res real-res))) +(let* ((v #*0011) + (form `(lambda () + (let ((v (bit-not ,v))) + (setf (aref v 0) (- 1 (aref v 0))) + (aref v 0)))) + (compiled-res (funcall (compile nil form))) + (real-res (- 1 (aref (funcall (eval #'bit-not) v) 0)))) + (assert (equal compiled-res real-res))) (sb-ext:quit :unix-status 104)