aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/emacs-lisp/byte-run.el1
-rw-r--r--lisp/emacs-lisp/bytecomp.el96
3 files changed, 65 insertions, 40 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4b670eb2f8b..70e10615dd7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12013-08-07 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/bytecomp.el: Check existence of f in #'f.
4 (byte-compile-callargs-warn): Use `push'.
5 (byte-compile-arglist-warn): Ignore higher-order "calls".
6 (byte-compile-file-form-autoload): Use `pcase'.
7 (byte-compile-function-form): If quoting a symbol, check that it exists.
8
12013-08-07 Eli Zaretskii <eliz@gnu.org> 92013-08-07 Eli Zaretskii <eliz@gnu.org>
2 10
3 * progmodes/dos.el (dos-font-lock-keywords): Rename LINUX to UNIX 11 * progmodes/dos.el (dos-font-lock-keywords): Rename LINUX to UNIX
diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el
index 8f0999b2f80..0bb04950dfd 100644
--- a/lisp/emacs-lisp/byte-run.el
+++ b/lisp/emacs-lisp/byte-run.el
@@ -83,7 +83,6 @@ The return value of this function is not used."
83 (list 'quote f) (list 'quote new-name) (list 'quote when)))) 83 (list 'quote f) (list 'quote new-name) (list 'quote when))))
84 (list 'compiler-macro 84 (list 'compiler-macro
85 #'(lambda (f args compiler-function) 85 #'(lambda (f args compiler-function)
86 ;; FIXME: Make it possible to just reuse `args'.
87 `(eval-and-compile 86 `(eval-and-compile
88 (put ',f 'compiler-macro 87 (put ',f 'compiler-macro
89 ,(if (eq (car-safe compiler-function) 'lambda) 88 ,(if (eq (car-safe compiler-function) 'lambda)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index f4e79dc4886..ce377dc5caf 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1273,7 +1273,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
1273 (n (length (cdr form)))) 1273 (n (length (cdr form))))
1274 (if cons 1274 (if cons
1275 (or (memq n (cdr cons)) 1275 (or (memq n (cdr cons))
1276 (setcdr cons (cons n (cdr cons)))) 1276 (push n (cdr cons)))
1277 (push (list (car form) n) 1277 (push (list (car form) n)
1278 byte-compile-unresolved-functions)))))) 1278 byte-compile-unresolved-functions))))))
1279 1279
@@ -1364,7 +1364,10 @@ extra args."
1364 ;; This is the first definition. See if previous calls are compatible. 1364 ;; This is the first definition. See if previous calls are compatible.
1365 (let ((calls (assq name byte-compile-unresolved-functions)) 1365 (let ((calls (assq name byte-compile-unresolved-functions))
1366 nums sig min max) 1366 nums sig min max)
1367 (when calls 1367 (setq byte-compile-unresolved-functions
1368 (delq calls byte-compile-unresolved-functions))
1369 (setq calls (delq t calls)) ;Ignore higher-order uses of the function.
1370 (when (cdr calls)
1368 (when (and (symbolp name) 1371 (when (and (symbolp name)
1369 (eq (function-get name 'byte-optimizer) 1372 (eq (function-get name 'byte-optimizer)
1370 'byte-compile-inline-expand)) 1373 'byte-compile-inline-expand))
@@ -1382,10 +1385,7 @@ extra args."
1382 name 1385 name
1383 (byte-compile-arglist-signature-string sig) 1386 (byte-compile-arglist-signature-string sig)
1384 (if (equal sig '(1 . 1)) " arg" " args") 1387 (if (equal sig '(1 . 1)) " arg" " args")
1385 (byte-compile-arglist-signature-string (cons min max)))) 1388 (byte-compile-arglist-signature-string (cons min max)))))))))
1386
1387 (setq byte-compile-unresolved-functions
1388 (delq calls byte-compile-unresolved-functions)))))))
1389 1389
1390(defvar byte-compile-cl-functions nil 1390(defvar byte-compile-cl-functions nil
1391 "List of functions defined in CL.") 1391 "List of functions defined in CL.")
@@ -2214,37 +2214,33 @@ list that represents a doc string reference.
2214(defun byte-compile-file-form-autoload (form) 2214(defun byte-compile-file-form-autoload (form)
2215 (and (let ((form form)) 2215 (and (let ((form form))
2216 (while (if (setq form (cdr form)) (macroexp-const-p (car form)))) 2216 (while (if (setq form (cdr form)) (macroexp-const-p (car form))))
2217 (null form)) ;Constants only 2217 (null form)) ;Constants only
2218 (memq (eval (nth 5 form)) '(t macro)) ;Macro 2218 (memq (eval (nth 5 form)) '(t macro)) ;Macro
2219 (eval form)) ;Define the autoload. 2219 (eval form)) ;Define the autoload.
2220 ;; Avoid undefined function warnings for the autoload. 2220 ;; Avoid undefined function warnings for the autoload.
2221 (when (and (consp (nth 1 form)) 2221 (pcase (nth 1 form)
2222 (eq (car (nth 1 form)) 'quote) 2222 (`',(and (pred symbolp) funsym)
2223 (consp (cdr (nth 1 form))) 2223 ;; Don't add it if it's already defined. Otherwise, it might
2224 (symbolp (nth 1 (nth 1 form)))) 2224 ;; hide the actual definition. However, do remove any entry from
2225 ;; Don't add it if it's already defined. Otherwise, it might 2225 ;; byte-compile-noruntime-functions, in case we have an autoload
2226 ;; hide the actual definition. However, do remove any entry from 2226 ;; of foo-func following an (eval-when-compile (require 'foo)).
2227 ;; byte-compile-noruntime-functions, in case we have an autoload 2227 (unless (fboundp funsym)
2228 ;; of foo-func following an (eval-when-compile (require 'foo)). 2228 (push (cons funsym (cons 'autoload (cdr (cdr form))))
2229 (unless (fboundp (nth 1 (nth 1 form))) 2229 byte-compile-function-environment))
2230 (push (cons (nth 1 (nth 1 form)) 2230 ;; If an autoload occurs _before_ the first call to a function,
2231 (cons 'autoload (cdr (cdr form)))) 2231 ;; byte-compile-callargs-warn does not add an entry to
2232 byte-compile-function-environment)) 2232 ;; byte-compile-unresolved-functions. Here we mimic the logic
2233 ;; If an autoload occurs _before_ the first call to a function, 2233 ;; of byte-compile-callargs-warn so as not to warn if the
2234 ;; byte-compile-callargs-warn does not add an entry to 2234 ;; autoload comes _after_ the function call.
2235 ;; byte-compile-unresolved-functions. Here we mimic the logic 2235 ;; Alternatively, similar logic could go in
2236 ;; of byte-compile-callargs-warn so as not to warn if the 2236 ;; byte-compile-warn-about-unresolved-functions.
2237 ;; autoload comes _after_ the function call. 2237 (if (memq funsym byte-compile-noruntime-functions)
2238 ;; Alternatively, similar logic could go in 2238 (setq byte-compile-noruntime-functions
2239 ;; byte-compile-warn-about-unresolved-functions. 2239 (delq funsym byte-compile-noruntime-functions)
2240 (if (memq (nth 1 (nth 1 form)) byte-compile-noruntime-functions) 2240 byte-compile-noruntime-functions)
2241 (setq byte-compile-noruntime-functions 2241 (setq byte-compile-unresolved-functions
2242 (delq (nth 1 (nth 1 form)) byte-compile-noruntime-functions) 2242 (delq (assq funsym byte-compile-unresolved-functions)
2243 byte-compile-noruntime-functions) 2243 byte-compile-unresolved-functions)))))
2244 (setq byte-compile-unresolved-functions
2245 (delq (assq (nth 1 (nth 1 form))
2246 byte-compile-unresolved-functions)
2247 byte-compile-unresolved-functions))))
2248 (if (stringp (nth 3 form)) 2244 (if (stringp (nth 3 form))
2249 form 2245 form
2250 ;; No doc string, so we can compile this as a normal form. 2246 ;; No doc string, so we can compile this as a normal form.
@@ -3574,10 +3570,32 @@ discarding."
3574;; and (funcall (function foo)) will lose with autoloads. 3570;; and (funcall (function foo)) will lose with autoloads.
3575 3571
3576(defun byte-compile-function-form (form) 3572(defun byte-compile-function-form (form)
3577 (byte-compile-constant (if (eq 'lambda (car-safe (nth 1 form))) 3573 (let ((f (nth 1 form)))
3578 (byte-compile-lambda (nth 1 form)) 3574 (when (and (symbolp f)
3579 (nth 1 form)))) 3575 (byte-compile-warning-enabled-p 'callargs))
3580 3576 (when (get f 'byte-obsolete-info)
3577 (byte-compile-warn-obsolete (car form)))
3578
3579 ;; Check to see if the function will be available at runtime
3580 ;; and/or remember its arity if it's unknown.
3581 (or (and (or (fboundp f) ; Might be a subr or autoload.
3582 (byte-compile-fdefinition (car form) nil))
3583 (not (memq f byte-compile-noruntime-functions)))
3584 (eq f byte-compile-current-form) ; ## This doesn't work
3585 ; with recursion.
3586 ;; It's a currently-undefined function.
3587 ;; Remember number of args in call.
3588 (let ((cons (assq f byte-compile-unresolved-functions)))
3589 (if cons
3590 (or (memq t (cdr cons))
3591 (push t (cdr cons)))
3592 (push (list f t)
3593 byte-compile-unresolved-functions)))))
3594
3595 (byte-compile-constant (if (eq 'lambda (car-safe f))
3596 (byte-compile-lambda f)
3597 f))))
3598
3581(defun byte-compile-indent-to (form) 3599(defun byte-compile-indent-to (form)
3582 (let ((len (length form))) 3600 (let ((len (length form)))
3583 (cond ((= len 2) 3601 (cond ((= len 2)