summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2019-06-22 23:29:00 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2019-06-22 23:29:00 -0400
commitb9d0337c84a6be7f26fd7134615048293320e234 (patch)
tree607f1980e12443e69c30d59827630894fe824418
parent2db75262c7395483d1fa9a0c9d93dd3e4d534e1f (diff)
downloademacs-b9d0337c84a6be7f26fd7134615048293320e234.tar.gz
(with-suppressed-warnings): Also suppress warnings when not byte-compiling
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): Bind byte-compile--suppressed-warnings when possible.
-rw-r--r--lisp/emacs-lisp/byte-run.el22
1 files changed, 17 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index d34d5d8a7e4..1115c096679 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -46,7 +46,7 @@ So far, FUNCTION can only be a symbol, not a lambda expression."
;; file) but used in many .elc files.
;; We don't use #' here, because it's an obsolete function, and we
-;; can't use `with-suppressed-errors' here due to how this file is
+;; can't use `with-suppressed-warnings' here due to how this file is
;; used in the bootstrapping process.
(defvar macro-declaration-function 'macro-declaration-function
"Function to process declarations in a macro definition.
@@ -497,7 +497,7 @@ is enabled."
;; The implementation for the interpreter is basically trivial.
(car (last body)))
-(defmacro with-suppressed-warnings (_warnings &rest body)
+(defmacro with-suppressed-warnings (warnings &rest body)
"Like `progn', but prevents compiler WARNINGS in BODY.
WARNINGS is an associative list where the first element of each
@@ -521,10 +521,22 @@ suppressed with this macro are `free-vars', `callargs',
For the `mapcar' case, only the `mapcar' function can be used in
the symbol list. For `suspicious', only `set-buffer' can be used."
+ ;; Note: during compilation, this definition is overridden by the one in
+ ;; byte-compile-initial-macro-environment.
(declare (debug (sexp &optional body)) (indent 1))
- ;; The implementation for the interpreter is basically trivial.
- `(progn ,@body))
-
+ (if (not (and (featurep 'macroexp)
+ (boundp 'byte-compile--suppressed-warnings)))
+ ;; If `macroexp' is not yet loaded, we're in the middle of
+ ;; bootstrapping, so better risk emitting too many warnings
+ ;; than risk breaking the bootstrap.
+ `(progn ,@body)
+ ;; We need to let-bind byte-compile--suppressed-warnings here, so as to
+ ;; silence warnings emitted during macro-expansion performed outside of
+ ;; byte-compilation.
+ (let ((byte-compile--suppressed-warnings
+ (append warnings byte-compile--suppressed-warnings)))
+ (macroexpand-all (macroexp-progn body)
+ macroexpand-all-environment))))
(defun byte-run--unescaped-character-literals-warning ()
"Return a warning about unescaped character literals.