Commit b68f207b authored by Lars Ingebrigtsen's avatar Lars Ingebrigtsen

Initial implementation

parent b7e26952
......@@ -494,6 +494,18 @@ is enabled."
;; The implementation for the interpreter is basically trivial.
(car (last body)))
(defmacro with-suppressed-warnings (warnings &rest body)
"Like `progn', but prevents compiler warnings in the body."
(declare (indent 1))
;; The implementation for the interpreter is basically trivial.
`(with-suppressed-warnings-1 ',warnings (progn ,@body)))
(defun with-suppressed-warnings-1 (_ &rest body)
"Like `progn', but prevents compiler warnings in the body."
(declare (indent 1))
;; The implementation for the interpreter is basically trivial.
(car (last body)))
(defun byte-run--unescaped-character-literals-warning ()
"Return a warning about unescaped character literals.
......
......@@ -331,18 +331,26 @@ suppress. For example, (not mapcar) will suppress warnings about mapcar."
,@(mapcar (lambda (x) `(const ,x))
byte-compile-warning-types))))
(defvar byte-compile-suppressed-warnings nil)
;;;###autoload
(put 'byte-compile-warnings 'safe-local-variable
(lambda (v)
(or (symbolp v)
(null (delq nil (mapcar (lambda (x) (not (symbolp x))) v))))))
(defun byte-compile-warning-enabled-p (warning)
(defun byte-compile-warning-enabled-p (warning &optional symbol)
"Return non-nil if WARNING is enabled, according to `byte-compile-warnings'."
(or (eq byte-compile-warnings t)
(if (eq (car byte-compile-warnings) 'not)
(not (memq warning byte-compile-warnings))
(memq warning byte-compile-warnings))))
(let ((suppress nil))
(dolist (elem byte-compile-suppressed-warnings)
(when (and (eq (car elem) warning)
(memq symbol (cdr elem)))
(setq suppress t)))
(and (not suppress)
(or (eq byte-compile-warnings t)
(if (eq (car byte-compile-warnings) 'not)
(not (memq warning byte-compile-warnings))
(memq warning byte-compile-warnings))))))
;;;###autoload
(defun byte-compile-disable-warning (warning)
......@@ -2520,6 +2528,15 @@ list that represents a doc string reference.
(mapc 'byte-compile-file-form (cdr form))
nil))
(put 'with-suppressed-warnings-1 'byte-hunk-handler
'byte-compile-file-form-with-suppressed-warnings)
(defun byte-compile-file-form-with-suppressed-warnings (form)
;; cf byte-compile-file-form-progn.
(let ((byte-compile-suppressed-warnings
(append (cadadr form) byte-compile-suppressed-warnings)))
(mapc 'byte-compile-file-form (cddr form))
nil))
;; Automatically evaluate define-obsolete-function-alias etc at top-level.
(put 'make-obsolete 'byte-hunk-handler 'byte-compile-file-form-make-obsolete)
(defun byte-compile-file-form-make-obsolete (form)
......@@ -3152,7 +3169,7 @@ for symbols generated by the byte compiler itself."
(when (and (byte-compile-warning-enabled-p 'suspicious)
(macroexp--const-symbol-p fn))
(byte-compile-warn "`%s' called as a function" fn))
(when (and (byte-compile-warning-enabled-p 'interactive-only)
(when (and (byte-compile-warning-enabled-p 'interactive-only fn)
interactive-only)
(byte-compile-warn "`%s' is for interactive use only%s"
fn
......@@ -4766,6 +4783,14 @@ binding slots have been popped."
(let (byte-compile-warnings)
(byte-compile-form (cons 'progn (cdr form)))))
(byte-defop-compiler-1 with-suppressed-warnings-1
byte-compile-suppressed-warnings)
(defun byte-compile-suppressed-warnings (form)
(let ((byte-compile-suppressed-warnings
(append (cadadr form) byte-compile-suppressed-warnings)))
(mapc 'byte-compile-file-form (cddr form))
nil))
;; Warn about misuses of make-variable-buffer-local.
(byte-defop-compiler-1 make-variable-buffer-local
byte-compile-make-variable-buffer-local)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment