diff options
| author | Chong Yidong | 2006-11-18 21:07:17 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-11-18 21:07:17 +0000 |
| commit | 26cc7ed550f2964a6e6b0258187e204c2f05f32d (patch) | |
| tree | 6dbd327b5b474548ccc40197c13d1016fb6e7f4e | |
| parent | f80832bcaae30fbf96b3f4452dd8239994f57b6d (diff) | |
| download | emacs-26cc7ed550f2964a6e6b0258187e204c2f05f32d.tar.gz emacs-26cc7ed550f2964a6e6b0258187e204c2f05f32d.zip | |
(byte-compile-maybe-guarded): Check `and' conditions for function or
variable bindings.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 02a88c13973..342ae2ab33a 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -3398,35 +3398,42 @@ being undefined will be suppressed. | |||
| 3398 | If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs), | 3398 | If CONDITION's value is (not (featurep 'emacs)) or (featurep 'xemacs), |
| 3399 | that suppresses all warnings during execution of BODY." | 3399 | that suppresses all warnings during execution of BODY." |
| 3400 | (declare (indent 1) (debug t)) | 3400 | (declare (indent 1) (debug t)) |
| 3401 | `(let* ((fbound | 3401 | `(let* ((byte-compile-warnings |
| 3402 | (if (eq 'fboundp (car-safe ,condition)) | 3402 | ;; Suppress all warnings, for code not used in Emacs. |
| 3403 | (and (eq 'quote (car-safe (nth 1 ,condition))) | ||
| 3404 | ;; Ignore if the symbol is already on the | ||
| 3405 | ;; unresolved list. | ||
| 3406 | (not (assq (nth 1 (nth 1 ,condition)) ; the relevant symbol | ||
| 3407 | byte-compile-unresolved-functions)) | ||
| 3408 | (nth 1 (nth 1 ,condition))))) | ||
| 3409 | (bound (if (or (eq 'boundp (car-safe ,condition)) | ||
| 3410 | (eq 'default-boundp (car-safe ,condition))) | ||
| 3411 | (and (eq 'quote (car-safe (nth 1 ,condition))) | ||
| 3412 | (nth 1 (nth 1 ,condition))))) | ||
| 3413 | ;; Maybe add to the bound list. | ||
| 3414 | (byte-compile-bound-variables | ||
| 3415 | (if bound | ||
| 3416 | (cons bound byte-compile-bound-variables) | ||
| 3417 | byte-compile-bound-variables)) | ||
| 3418 | ;; Suppress all warnings, for code not used in Emacs. | ||
| 3419 | (byte-compile-warnings | ||
| 3420 | (if (member ,condition '((featurep 'xemacs) | 3403 | (if (member ,condition '((featurep 'xemacs) |
| 3421 | (not (featurep 'emacs)))) | 3404 | (not (featurep 'emacs)))) |
| 3422 | nil byte-compile-warnings))) | 3405 | nil |
| 3406 | byte-compile-warnings)) | ||
| 3407 | (byte-compile-bound-variables byte-compile-bound-variables) | ||
| 3408 | binding fbound-list) | ||
| 3409 | (mapc (lambda (subcondition) | ||
| 3410 | (cond ((eq 'fboundp (car-safe subcondition)) | ||
| 3411 | (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) | ||
| 3412 | ;; Ignore if the symbol is already on the | ||
| 3413 | ;; unresolved list. | ||
| 3414 | (not (assq (nth 1 (nth 1 subcondition)) | ||
| 3415 | byte-compile-unresolved-functions)) | ||
| 3416 | (nth 1 (nth 1 subcondition)))) | ||
| 3417 | (if binding (setq fbound-list (cons binding fbound-list)))) | ||
| 3418 | ((or (eq 'boundp (car-safe subcondition)) | ||
| 3419 | (eq 'default-boundp (car-safe subcondition))) | ||
| 3420 | (setq binding (and (eq 'quote (car-safe (nth 1 subcondition))) | ||
| 3421 | (nth 1 (nth 1 subcondition)))) | ||
| 3422 | (if binding (setq byte-compile-bound-variables | ||
| 3423 | (cons binding byte-compile-bound-variables)))))) | ||
| 3424 | ;; Inspect each element in an `and' condition; otherwise, | ||
| 3425 | ;; inspect the condition itself. | ||
| 3426 | (if (eq 'and (car-safe ,condition)) | ||
| 3427 | (cdr ,condition) | ||
| 3428 | (list ,condition))) | ||
| 3423 | (unwind-protect | 3429 | (unwind-protect |
| 3424 | (progn ,@body) | 3430 | (progn ,@body) |
| 3425 | ;; Maybe remove the function symbol from the unresolved list. | 3431 | ;; Maybe remove the function symbol from the unresolved list. |
| 3426 | (if fbound | 3432 | (mapc (lambda (fun) |
| 3427 | (setq byte-compile-unresolved-functions | 3433 | (setq byte-compile-unresolved-functions |
| 3428 | (delq (assq fbound byte-compile-unresolved-functions) | 3434 | (delq (assq fun byte-compile-unresolved-functions) |
| 3429 | byte-compile-unresolved-functions)))))) | 3435 | byte-compile-unresolved-functions))) |
| 3436 | fbound-list)))) | ||
| 3430 | 3437 | ||
| 3431 | (defun byte-compile-if (form) | 3438 | (defun byte-compile-if (form) |
| 3432 | (byte-compile-form (car (cdr form))) | 3439 | (byte-compile-form (car (cdr form))) |