Commit 9290191f authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(byte-compile-warning-types): Add obsolete.

(byte-compile-warnings): Doc fix.
(byte-compile-obsolete): Check for obsolete in byte-compile-warnings.
(byte-compile-variable-ref): Likewise.
parent 13d76d1c
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
;;; 'redefine (function cell redefined from ;;; 'redefine (function cell redefined from
;;; a macro to a lambda or vice versa, ;;; a macro to a lambda or vice versa,
;;; or redefined to take other args) ;;; or redefined to take other args)
;;; 'obsolete (obsolete variables and functions)
;;; byte-compile-compatibility Whether the compiler should ;;; byte-compile-compatibility Whether the compiler should
;;; generate .elc files which can be loaded into ;;; generate .elc files which can be loaded into
;;; generic emacs 18. ;;; generic emacs 18.
...@@ -277,7 +278,8 @@ If it is 'byte, then only byte-level optimizations will be logged.") ...@@ -277,7 +278,8 @@ If it is 'byte, then only byte-level optimizations will be logged.")
(defvar byte-compile-error-on-warn nil (defvar byte-compile-error-on-warn nil
"*If true, the byte-compiler reports warnings with `error'.") "*If true, the byte-compiler reports warnings with `error'.")
(defconst byte-compile-warning-types '(redefine callargs free-vars unresolved)) (defconst byte-compile-warning-types
'(redefine callargs free-vars unresolved obsolete))
(defvar byte-compile-warnings t (defvar byte-compile-warnings t
"*List of warnings that the byte-compiler should issue (t for all). "*List of warnings that the byte-compiler should issue (t for all).
Elements of the list may be be: Elements of the list may be be:
...@@ -287,6 +289,7 @@ Elements of the list may be be: ...@@ -287,6 +289,7 @@ Elements of the list may be be:
callargs lambda calls with args that don't match the definition. callargs lambda calls with args that don't match the definition.
redefine function cell redefined from a macro to a lambda or vice redefine function cell redefined from a macro to a lambda or vice
versa, or redefined to take a different number of arguments. versa, or redefined to take a different number of arguments.
obsolete obsolete variables and functions.
See also the macro `byte-compiler-options'.") See also the macro `byte-compiler-options'.")
...@@ -788,12 +791,13 @@ otherwise pop it") ...@@ -788,12 +791,13 @@ otherwise pop it")
;;; Used by make-obsolete. ;;; Used by make-obsolete.
(defun byte-compile-obsolete (form) (defun byte-compile-obsolete (form)
(let ((new (get (car form) 'byte-obsolete-info))) (if (memq 'obsolete byte-compile-warnings)
(byte-compile-warn "%s is an obsolete function; %s" (car form) (let ((new (get (car form) 'byte-obsolete-info)))
(if (stringp (car new)) (byte-compile-warn "%s is an obsolete function; %s" (car form)
(car new) (if (stringp (car new))
(format "use %s instead." (car new)))) (car new)
(funcall (or (cdr new) 'byte-compile-normal-call) form))) (format "use %s instead." (car new))))
(funcall (or (cdr new) 'byte-compile-normal-call) form))))
;; Compiler options ;; Compiler options
...@@ -2057,7 +2061,8 @@ If FORM is a lambda or a macro, byte-compile it as a function." ...@@ -2057,7 +2061,8 @@ If FORM is a lambda or a macro, byte-compile it as a function."
"Variable reference to %s %s") "Variable reference to %s %s")
(if (symbolp var) "constant" "nonvariable") (if (symbolp var) "constant" "nonvariable")
(prin1-to-string var)) (prin1-to-string var))
(if (get var 'byte-obsolete-variable) (if (and (get var 'byte-obsolete-variable)
(memq 'obsolete byte-compile-warnings))
(let ((ob (get var 'byte-obsolete-variable))) (let ((ob (get var 'byte-obsolete-variable)))
(byte-compile-warn "%s is an obsolete variable; %s" var (byte-compile-warn "%s is an obsolete variable; %s" var
(if (stringp ob) (if (stringp ob)
......
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