327 |
:type 'boolean) |
:type 'boolean) |
328 |
|
|
329 |
(defconst byte-compile-warning-types |
(defconst byte-compile-warning-types |
330 |
'(redefine callargs free-vars unresolved obsolete noruntime)) |
'(redefine callargs free-vars unresolved obsolete noruntime cl-functions) |
331 |
|
"The list of warning types used when `byte-compile-warnings' is t.") |
332 |
(defcustom byte-compile-warnings t |
(defcustom byte-compile-warnings t |
333 |
"*List of warnings that the byte-compiler should issue (t for all). |
"*List of warnings that the byte-compiler should issue (t for all). |
334 |
|
|
335 |
Elements of the list may be be: |
Elements of the list may be be: |
336 |
|
|
337 |
free-vars references to variables not in the current lexical scope. |
free-vars references to variables not in the current lexical scope. |
339 |
callargs lambda calls with args that don't match the definition. |
callargs lambda calls with args that don't match the definition. |
340 |
redefine function cell redefined from a macro to a lambda or vice |
redefine function cell redefined from a macro to a lambda or vice |
341 |
versa, or redefined to take a different number of arguments. |
versa, or redefined to take a different number of arguments. |
342 |
obsolete obsolete variables and functions." |
obsolete obsolete variables and functions. |
343 |
|
noruntime functions that may not be defined at runtime (typically |
344 |
|
defined only under `eval-when-compile'). |
345 |
|
cl-functions calls to runtime functions from the CL package (as |
346 |
|
distinguished from macros and aliases)." |
347 |
:group 'bytecomp |
:group 'bytecomp |
348 |
:type '(choice (const :tag "All" t) |
:type `(choice (const :tag "All" t) |
349 |
(set :menu-tag "Some" |
(set :menu-tag "Some" |
350 |
(const free-vars) (const unresolved) |
(const free-vars) (const unresolved) |
351 |
(const callargs) (const redefined) |
(const callargs) (const redefine) |
352 |
(const obsolete) (const noruntime)))) |
(const obsolete) (const noruntime) (const cl-functions)))) |
353 |
|
|
354 |
(defcustom byte-compile-generate-call-tree nil |
(defcustom byte-compile-generate-call-tree nil |
355 |
"*Non-nil means collect call-graph information when compiling. |
"*Non-nil means collect call-graph information when compiling. |
417 |
(byte-compile-eval (byte-compile-top-level |
(byte-compile-eval (byte-compile-top-level |
418 |
(cons 'progn body)))))) |
(cons 'progn body)))))) |
419 |
(eval-and-compile . (lambda (&rest body) |
(eval-and-compile . (lambda (&rest body) |
420 |
(eval (cons 'progn body)) |
(byte-compile-eval-before-compile (cons 'progn body)) |
421 |
(cons 'progn body)))) |
(cons 'progn body)))) |
422 |
"The default macro-environment passed to macroexpand by the compiler. |
"The default macro-environment passed to macroexpand by the compiler. |
423 |
Placing a macro here will cause a macro to have different semantics when |
Placing a macro here will cause a macro to have different semantics when |
796 |
(when (symbolp s) |
(when (symbolp s) |
797 |
(put s 'byte-compile-noruntime t))))))))) |
(put s 'byte-compile-noruntime t))))))))) |
798 |
|
|
799 |
|
(defun byte-compile-eval-before-compile (form) |
800 |
|
"Evaluate FORM for `eval-and-compile'." |
801 |
|
(let ((hist-nil-orig current-load-list)) |
802 |
|
(prog1 (eval form) |
803 |
|
;; (eval-and-compile (require 'cl) turns off warnings for cl functions. |
804 |
|
(let ((tem current-load-list)) |
805 |
|
(while (not (eq tem hist-nil-orig)) |
806 |
|
(when (equal (car tem) '(require . cl)) |
807 |
|
(setq byte-compile-warnings |
808 |
|
(remq 'cl-functions byte-compile-warnings))) |
809 |
|
(setq tem (cdr tem))))))) |
810 |
|
|
811 |
;;; byte compiler messages |
;;; byte compiler messages |
812 |
|
|
1192 |
(delq calls byte-compile-unresolved-functions))))) |
(delq calls byte-compile-unresolved-functions))))) |
1193 |
))) |
))) |
1194 |
|
|
1195 |
|
(defun byte-compile-cl-warn (form) |
1196 |
|
"Warn if FORM is a call of a function from the CL package." |
1197 |
|
(let* ((func (car-safe form)) |
1198 |
|
(library |
1199 |
|
(if func |
1200 |
|
(cond ((eq (car-safe func) 'autoload) |
1201 |
|
(nth 1 func)) |
1202 |
|
((symbol-file func)))))) |
1203 |
|
(if (and library |
1204 |
|
(string-match "^cl\\>" library) |
1205 |
|
;; Aliases which won't have been expended at this point. |
1206 |
|
;; These aren't all aliases of subrs, so not trivial to |
1207 |
|
;; avoid hardwiring the list. |
1208 |
|
(not (memq func |
1209 |
|
'(cl-block-wrapper cl-block-throw values values-list |
1210 |
|
multiple-value-list multiple-value-call nth-value |
1211 |
|
copy-seq first second rest endp cl-member)))) |
1212 |
|
(byte-compile-warn "Function `%s' from cl package called at runtime" |
1213 |
|
func))) |
1214 |
|
form) |
1215 |
|
|
1216 |
(defun byte-compile-print-syms (str1 strn syms) |
(defun byte-compile-print-syms (str1 strn syms) |
1217 |
(when syms |
(when syms |
1218 |
(byte-compile-set-symbol-position (car syms) t)) |
(byte-compile-set-symbol-position (car syms) t)) |
2008 |
|
|
2009 |
(put 'require 'byte-hunk-handler 'byte-compile-file-form-eval-boundary) |
(put 'require 'byte-hunk-handler 'byte-compile-file-form-eval-boundary) |
2010 |
(defun byte-compile-file-form-eval-boundary (form) |
(defun byte-compile-file-form-eval-boundary (form) |
2011 |
(eval form) |
(let ((old-load-list current-load-list)) |
2012 |
|
(eval form) |
2013 |
|
;; (require 'cl) turns off warnings for cl functions. |
2014 |
|
(let ((tem current-load-list)) |
2015 |
|
(while (not (eq tem old-load-list)) |
2016 |
|
(when (equal (car tem) '(require . cl)) |
2017 |
|
(setq byte-compile-warnings |
2018 |
|
(remq 'cl-functions byte-compile-warnings))) |
2019 |
|
(setq tem (cdr tem))))) |
2020 |
(byte-compile-keep-pending form 'byte-compile-normal-call)) |
(byte-compile-keep-pending form 'byte-compile-normal-call)) |
2021 |
|
|
2022 |
(put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn) |
(put 'progn 'byte-hunk-handler 'byte-compile-file-form-progn) |
2567 |
(funcall handler form) |
(funcall handler form) |
2568 |
(if (memq 'callargs byte-compile-warnings) |
(if (memq 'callargs byte-compile-warnings) |
2569 |
(byte-compile-callargs-warn form)) |
(byte-compile-callargs-warn form)) |
2570 |
(byte-compile-normal-call form)))) |
(byte-compile-normal-call form)) |
2571 |
|
(if (memq 'cl-functions byte-compile-warnings) |
2572 |
|
(byte-compile-cl-warn form)))) |
2573 |
((and (or (byte-code-function-p (car form)) |
((and (or (byte-code-function-p (car form)) |
2574 |
(eq (car-safe (car form)) 'lambda)) |
(eq (car-safe (car form)) 'lambda)) |
2575 |
;; if the form comes out the same way it went in, that's |
;; if the form comes out the same way it went in, that's |