comparison lisp/emacs-lisp/bytecomp.el @ 10256:83d56dd99a40

(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.
author Richard M. Stallman <rms@gnu.org>
date Mon, 26 Dec 1994 01:28:59 +0000
parents ff7189e5e459
children bdf897e70017
comparison
equal deleted inserted replaced
10255:d4119f1137f9 10256:83d56dd99a40
95 ;;; 'callargs (lambda calls with args that don't 95 ;;; 'callargs (lambda calls with args that don't
96 ;;; match the lambda's definition) 96 ;;; match the lambda's definition)
97 ;;; 'redefine (function cell redefined from 97 ;;; 'redefine (function cell redefined from
98 ;;; a macro to a lambda or vice versa, 98 ;;; a macro to a lambda or vice versa,
99 ;;; or redefined to take other args) 99 ;;; or redefined to take other args)
100 ;;; 'obsolete (obsolete variables and functions)
100 ;;; byte-compile-compatibility Whether the compiler should 101 ;;; byte-compile-compatibility Whether the compiler should
101 ;;; generate .elc files which can be loaded into 102 ;;; generate .elc files which can be loaded into
102 ;;; generic emacs 18. 103 ;;; generic emacs 18.
103 ;;; emacs-lisp-file-regexp Regexp for the extension of source-files; 104 ;;; emacs-lisp-file-regexp Regexp for the extension of source-files;
104 ;;; see also the function byte-compile-dest-file. 105 ;;; see also the function byte-compile-dest-file.
275 If it is 'byte, then only byte-level optimizations will be logged.") 276 If it is 'byte, then only byte-level optimizations will be logged.")
276 277
277 (defvar byte-compile-error-on-warn nil 278 (defvar byte-compile-error-on-warn nil
278 "*If true, the byte-compiler reports warnings with `error'.") 279 "*If true, the byte-compiler reports warnings with `error'.")
279 280
280 (defconst byte-compile-warning-types '(redefine callargs free-vars unresolved)) 281 (defconst byte-compile-warning-types
282 '(redefine callargs free-vars unresolved obsolete))
281 (defvar byte-compile-warnings t 283 (defvar byte-compile-warnings t
282 "*List of warnings that the byte-compiler should issue (t for all). 284 "*List of warnings that the byte-compiler should issue (t for all).
283 Elements of the list may be be: 285 Elements of the list may be be:
284 286
285 free-vars references to variables not in the current lexical scope. 287 free-vars references to variables not in the current lexical scope.
286 unresolved calls to unknown functions. 288 unresolved calls to unknown functions.
287 callargs lambda calls with args that don't match the definition. 289 callargs lambda calls with args that don't match the definition.
288 redefine function cell redefined from a macro to a lambda or vice 290 redefine function cell redefined from a macro to a lambda or vice
289 versa, or redefined to take a different number of arguments. 291 versa, or redefined to take a different number of arguments.
292 obsolete obsolete variables and functions.
290 293
291 See also the macro `byte-compiler-options'.") 294 See also the macro `byte-compiler-options'.")
292 295
293 (defvar byte-compile-generate-call-tree nil 296 (defvar byte-compile-generate-call-tree nil
294 "*Non-nil means collect call-graph information when compiling. 297 "*Non-nil means collect call-graph information when compiling.
786 (get (car error-info) 'error-message) 789 (get (car error-info) 'error-message)
787 (prin1-to-string (cdr error-info)))))) 790 (prin1-to-string (cdr error-info))))))
788 791
789 ;;; Used by make-obsolete. 792 ;;; Used by make-obsolete.
790 (defun byte-compile-obsolete (form) 793 (defun byte-compile-obsolete (form)
791 (let ((new (get (car form) 'byte-obsolete-info))) 794 (if (memq 'obsolete byte-compile-warnings)
792 (byte-compile-warn "%s is an obsolete function; %s" (car form) 795 (let ((new (get (car form) 'byte-obsolete-info)))
793 (if (stringp (car new)) 796 (byte-compile-warn "%s is an obsolete function; %s" (car form)
794 (car new) 797 (if (stringp (car new))
795 (format "use %s instead." (car new)))) 798 (car new)
796 (funcall (or (cdr new) 'byte-compile-normal-call) form))) 799 (format "use %s instead." (car new))))
800 (funcall (or (cdr new) 'byte-compile-normal-call) form))))
797 801
798 ;; Compiler options 802 ;; Compiler options
799 803
800 ;; (defvar byte-compiler-valid-options 804 ;; (defvar byte-compiler-valid-options
801 ;; '((optimize byte-optimize (t nil source byte) val) 805 ;; '((optimize byte-optimize (t nil source byte) val)
2055 (byte-compile-warn (if (eq base-op 'byte-varbind) 2059 (byte-compile-warn (if (eq base-op 'byte-varbind)
2056 "Attempt to let-bind %s %s" 2060 "Attempt to let-bind %s %s"
2057 "Variable reference to %s %s") 2061 "Variable reference to %s %s")
2058 (if (symbolp var) "constant" "nonvariable") 2062 (if (symbolp var) "constant" "nonvariable")
2059 (prin1-to-string var)) 2063 (prin1-to-string var))
2060 (if (get var 'byte-obsolete-variable) 2064 (if (and (get var 'byte-obsolete-variable)
2065 (memq 'obsolete byte-compile-warnings))
2061 (let ((ob (get var 'byte-obsolete-variable))) 2066 (let ((ob (get var 'byte-obsolete-variable)))
2062 (byte-compile-warn "%s is an obsolete variable; %s" var 2067 (byte-compile-warn "%s is an obsolete variable; %s" var
2063 (if (stringp ob) 2068 (if (stringp ob)
2064 ob 2069 ob
2065 (format "use %s instead." ob))))) 2070 (format "use %s instead." ob)))))