diff options
| author | Alan Mackenzie | 2015-11-24 17:37:49 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2015-11-24 17:37:49 +0000 |
| commit | acb96f2718ccb0d36af514ce63b5decf0f24a697 (patch) | |
| tree | 5c01fa026f85b197f853fd85e67f94843cb3a13f | |
| parent | a67cc630db28cf734d0e47f231add30c782bd8cf (diff) | |
| download | emacs-acb96f2718ccb0d36af514ce63b5decf0f24a697.tar.gz emacs-acb96f2718ccb0d36af514ce63b5decf0f24a697.zip | |
Squashed commit of the following:
commit e1ecf76585bef2eb87995f7a7f92cc12003a6f70
Author: Alan Mackenzie <acm@muc.de>
Date: Tue Nov 24 16:50:09 2015 +0000
Byte compile: minor amendments.
* lisp/emacs-lisp/bytecomp.el (byte-compile-initial-macro-environment):
add a comment to explain the binding of variables around a subsidiary
compilation.
(byte-compile-new-defuns): Amend the doc string.
commit c537bfed1dda1593d218956ff00c6105a3ff0316
Author: Alan Mackenzie <acm@muc.de>
Date: Sat Nov 21 18:43:57 2015 +0000
Byte compiler: fix spurious warnings "might not be defined at runtime".
Also initialize byte-compile-noruntime-functions between runs.
* lisp/emacs-lisp/bytecomp.el (byte-compile-new-defuns): New variable.
(byte-compile-initial-macro-environment): For eval-when-compile: bind
byte-compile-unresolved-functions and byte-compile-new-defuns around
byte-compile-top-level, to prevent spurious entries being made.
(byte-compile-warn-about-unresolved-functions): Check whether function is
in byte-compile-new-defuns before emitting a warning about it.
(byte-compile-from-buffer): Initialize new variable and
byte-compile-noruntime-functions to nil.
(byte-compile-file-form-require): record all new functions defined by a
`require' in byte-compile-new-defuns.
(byte-compile-file-form-defmumble): record the new alias in
byte-compile-new-defuns.
| -rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 5e6df282b3f..58cce67598c 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el | |||
| @@ -456,10 +456,20 @@ Return the compile-time value of FORM." | |||
| 456 | (byte-compile-recurse-toplevel | 456 | (byte-compile-recurse-toplevel |
| 457 | (macroexp-progn body) | 457 | (macroexp-progn body) |
| 458 | (lambda (form) | 458 | (lambda (form) |
| 459 | (setf result | 459 | ;; Insulate the following variables |
| 460 | (byte-compile-eval | 460 | ;; against changes made in the |
| 461 | (byte-compile-top-level | 461 | ;; subsidiary compilation. This |
| 462 | (byte-compile-preprocess form)))))) | 462 | ;; prevents spurious warning |
| 463 | ;; messages: "not defined at runtime" | ||
| 464 | ;; etc. | ||
| 465 | (let ((byte-compile-unresolved-functions | ||
| 466 | byte-compile-unresolved-functions) | ||
| 467 | (byte-compile-new-defuns | ||
| 468 | byte-compile-new-defuns)) | ||
| 469 | (setf result | ||
| 470 | (byte-compile-eval | ||
| 471 | (byte-compile-top-level | ||
| 472 | (byte-compile-preprocess form))))))) | ||
| 463 | (list 'quote result)))) | 473 | (list 'quote result)))) |
| 464 | (eval-and-compile . ,(lambda (&rest body) | 474 | (eval-and-compile . ,(lambda (&rest body) |
| 465 | (byte-compile-recurse-toplevel | 475 | (byte-compile-recurse-toplevel |
| @@ -503,6 +513,11 @@ defined with incorrect args.") | |||
| 503 | Used for warnings about calling a function that is defined during compilation | 513 | Used for warnings about calling a function that is defined during compilation |
| 504 | but won't necessarily be defined when the compiled file is loaded.") | 514 | but won't necessarily be defined when the compiled file is loaded.") |
| 505 | 515 | ||
| 516 | (defvar byte-compile-new-defuns nil | ||
| 517 | "List of (runtime) functions defined in this compilation run. | ||
| 518 | This variable is used to qualify `byte-compile-noruntime-functions' when | ||
| 519 | outputting warnings about functions not being defined at runtime.") | ||
| 520 | |||
| 506 | ;; Variables for lexical binding | 521 | ;; Variables for lexical binding |
| 507 | (defvar byte-compile--lexical-environment nil | 522 | (defvar byte-compile--lexical-environment nil |
| 508 | "The current lexical environment.") | 523 | "The current lexical environment.") |
| @@ -1503,8 +1518,9 @@ extra args." | |||
| 1503 | ;; Separate the functions that will not be available at runtime | 1518 | ;; Separate the functions that will not be available at runtime |
| 1504 | ;; from the truly unresolved ones. | 1519 | ;; from the truly unresolved ones. |
| 1505 | (dolist (f byte-compile-unresolved-functions) | 1520 | (dolist (f byte-compile-unresolved-functions) |
| 1506 | (setq f (car f)) | 1521 | (setq f (car f)) |
| 1507 | (if (fboundp f) (push f noruntime) (push f unresolved))) | 1522 | (when (not (memq f byte-compile-new-defuns)) |
| 1523 | (if (fboundp f) (push f noruntime) (push f unresolved)))) | ||
| 1508 | ;; Complain about the no-run-time functions | 1524 | ;; Complain about the no-run-time functions |
| 1509 | (byte-compile-print-syms | 1525 | (byte-compile-print-syms |
| 1510 | "the function `%s' might not be defined at runtime." | 1526 | "the function `%s' might not be defined at runtime." |
| @@ -1961,6 +1977,8 @@ With argument ARG, insert value in current buffer after the form." | |||
| 1961 | ;; compiled. A: Yes! b-c-u-f might contain dross from a | 1977 | ;; compiled. A: Yes! b-c-u-f might contain dross from a |
| 1962 | ;; previous byte-compile. | 1978 | ;; previous byte-compile. |
| 1963 | (setq byte-compile-unresolved-functions nil) | 1979 | (setq byte-compile-unresolved-functions nil) |
| 1980 | (setq byte-compile-noruntime-functions nil) | ||
| 1981 | (setq byte-compile-new-defuns nil) | ||
| 1964 | 1982 | ||
| 1965 | ;; Compile the forms from the input buffer. | 1983 | ;; Compile the forms from the input buffer. |
| 1966 | (while (progn | 1984 | (while (progn |
| @@ -2345,8 +2363,21 @@ list that represents a doc string reference. | |||
| 2345 | (defun byte-compile-file-form-require (form) | 2363 | (defun byte-compile-file-form-require (form) |
| 2346 | (let ((args (mapcar 'eval (cdr form))) | 2364 | (let ((args (mapcar 'eval (cdr form))) |
| 2347 | (hist-orig load-history) | 2365 | (hist-orig load-history) |
| 2348 | hist-new) | 2366 | hist-new prov-cons) |
| 2349 | (apply 'require args) | 2367 | (apply 'require args) |
| 2368 | |||
| 2369 | ;; Record the functions defined by the require in `byte-compille-new-defuns'. | ||
| 2370 | (setq hist-new load-history) | ||
| 2371 | (setq prov-cons (cons 'provide (car args))) | ||
| 2372 | (while (and hist-new | ||
| 2373 | (not (member prov-cons (car hist-new)))) | ||
| 2374 | (setq hist-new (cdr hist-new))) | ||
| 2375 | (when hist-new | ||
| 2376 | (dolist (x (car hist-new)) | ||
| 2377 | (when (and (consp x) | ||
| 2378 | (memq (car x) '(defun t))) | ||
| 2379 | (push (cdr x) byte-compile-new-defuns)))) | ||
| 2380 | |||
| 2350 | (when (byte-compile-warning-enabled-p 'cl-functions) | 2381 | (when (byte-compile-warning-enabled-p 'cl-functions) |
| 2351 | ;; Detect (require 'cl) in a way that works even if cl is already loaded. | 2382 | ;; Detect (require 'cl) in a way that works even if cl is already loaded. |
| 2352 | (if (member (car args) '("cl" cl)) | 2383 | (if (member (car args) '("cl" cl)) |
| @@ -2402,6 +2433,7 @@ not to take responsibility for the actual compilation of the code." | |||
| 2402 | (byte-compile-current-form name)) ; For warnings. | 2433 | (byte-compile-current-form name)) ; For warnings. |
| 2403 | 2434 | ||
| 2404 | (byte-compile-set-symbol-position name) | 2435 | (byte-compile-set-symbol-position name) |
| 2436 | (push name byte-compile-new-defuns) | ||
| 2405 | ;; When a function or macro is defined, add it to the call tree so that | 2437 | ;; When a function or macro is defined, add it to the call tree so that |
| 2406 | ;; we can tell when functions are not used. | 2438 | ;; we can tell when functions are not used. |
| 2407 | (if byte-compile-generate-call-tree | 2439 | (if byte-compile-generate-call-tree |