From ead23f685bb8630c080761e0120258366b90f6a0 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 18 Jun 2009 09:32:45 +0000 Subject: [PATCH] 1.0.29.16: make the fopcompiler DEFGLOBAL-aware MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Thanks to Lars Rune Nøstdal. --- NEWS | 2 ++ src/compiler/fopcompile.lisp | 44 +++++++++++++++++++++++++------------------- tests/defglobal.impure.lisp | 8 ++++++++ version.lisp-expr | 2 +- 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 6530578b3..626b6d771 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,8 @@ Michael Becker, Gabriel Dos Reis, and Cyrus Harmon) * bug fix: :PTY option in RUN-PROGRAM was broken with stream arguments. (reported by Elliot Slaughter, thanks to Stas Boukarev) + * bug fix: bogus undefined variable warnings from fopcompiled references to + global variables. (thanks to Lars Rune Nøstdal) changes in sbcl-1.0.29 relative to 1.0.28: * IMPORTANT: bug database has moved from the BUGS file to Launchpad diff --git a/src/compiler/fopcompile.lisp b/src/compiler/fopcompile.lisp index b1cbefe21..266bcc673 100644 --- a/src/compiler/fopcompile.lisp +++ b/src/compiler/fopcompile.lisp @@ -249,25 +249,31 @@ ;; Symbol macro (fopcompile macroexpansion path for-value-p) (let ((kind (info :variable :kind form))) - (if (member kind '(:special :constant)) - ;; Special variable - (fopcompile `(symbol-value ',form) path for-value-p) - ;; Lexical - (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*)))) - (handle (when lambda-var - (lambda-var-fop-value lambda-var)))) - (if handle - (when for-value-p - (sb!fasl::dump-push handle *compile-object*)) - (progn - ;; Undefined variable. Signal a warning, and - ;; treat it as a special variable reference, like - ;; the real compiler does -- do not elide even if - ;; the value is unused. - (note-undefined-reference form :variable) - (fopcompile `(symbol-value ',form) - path - for-value-p))))))))) + (cond + ((eq :special kind) + ;; Special variable + (fopcompile `(symbol-value ',form) path for-value-p)) + + ((member kind '(:global :constant)) + ;; Global variable or constant. + (fopcompile `(symbol-global-value ',form) path for-value-p)) + (t + ;; Lexical + (let* ((lambda-var (cdr (assoc form (lexenv-vars *lexenv*)))) + (handle (when lambda-var + (lambda-var-fop-value lambda-var)))) + (if handle + (when for-value-p + (sb!fasl::dump-push handle *compile-object*)) + (progn + ;; Undefined variable. Signal a warning, and + ;; treat it as a special variable reference, like + ;; the real compiler does -- do not elide even if + ;; the value is unused. + (note-undefined-reference form :variable) + (fopcompile `(symbol-value ',form) + path + for-value-p)))))))))) ((listp form) (multiple-value-bind (macroexpansion macroexpanded-p) (sb!xc:macroexpand form *lexenv*) diff --git a/tests/defglobal.impure.lisp b/tests/defglobal.impure.lisp index 68a74e2b6..5b5e63469 100644 --- a/tests/defglobal.impure.lisp +++ b/tests/defglobal.impure.lisp @@ -194,3 +194,11 @@ (ignore-errors (delete-file fasl))) (assert (= 1 *counter*)) (assert (= 1 (symbol-value '.counter-3.))))) + +(with-test (:name :defglobal-refers-to-defglobal) + (let ((fasl (compile-form `(progn + (defglobal **global-1** :fii) + (defglobal **global-2** **global-1**))))) + (load fasl) + (assert (eq (symbol-value '**global-1**) (symbol-value '**global-2**))) + (assert (eq :fii (symbol-value '**global-1**))))) diff --git a/version.lisp-expr b/version.lisp-expr index b8588b7c1..6b57f10f9 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"1.0.29.15" +"1.0.29.16" -- 2.11.4.GIT