summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-08-07 21:37:47 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-08-07 21:37:47 -0400
commitc735544cede2fa856d62addf7e71efe39142132c (patch)
treef2ed1179b547dcacf77f3ca0b3cd0a138ad01561 /lisp/emacs-lisp
parent3677ffeb2844f86cb0aa2852a1cb495c49ff9f81 (diff)
downloademacs-c735544cede2fa856d62addf7e71efe39142132c.tar.gz
emacs-c735544cede2fa856d62addf7e71efe39142132c.tar.bz2
emacs-c735544cede2fa856d62addf7e71efe39142132c.zip
* lisp/emacs-lisp/bytecomp.el (byte-compile-function-warn): New function,
extracted from byte-compile-callargs-warn and byte-compile-normal-call. (byte-compile-callargs-warn, byte-compile-function-form): Use it. (byte-compile-normal-call): Remove obsolescence check.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el55
1 files changed, 20 insertions, 35 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index ce377dc5caf..5baef042757 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1224,6 +1224,24 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
(format "%d" (car signature)))
(t (format "%d-%d" (car signature) (cdr signature)))))
+(defun byte-compile-function-warn (f nargs def)
+ (when (get f 'byte-obsolete-info)
+ (byte-compile-warn-obsolete f))
+
+ ;; Check to see if the function will be available at runtime
+ ;; and/or remember its arity if it's unknown.
+ (or (and (or def (fboundp f)) ; might be a subr or autoload.
+ (not (memq f byte-compile-noruntime-functions)))
+ (eq f byte-compile-current-form) ; ## This doesn't work
+ ; with recursion.
+ ;; It's a currently-undefined function.
+ ;; Remember number of args in call.
+ (let ((cons (assq f byte-compile-unresolved-functions)))
+ (if cons
+ (or (memq nargs (cdr cons))
+ (push nargs (cdr cons)))
+ (push (list f nargs)
+ byte-compile-unresolved-functions)))))
;; Warn if the form is calling a function with the wrong number of arguments.
(defun byte-compile-callargs-warn (form)
@@ -1261,21 +1279,7 @@ Each function's symbol gets added to `byte-compile-noruntime-functions'."
"accepts only")
(byte-compile-arglist-signature-string sig))))
(byte-compile-format-warn form)
- ;; Check to see if the function will be available at runtime
- ;; and/or remember its arity if it's unknown.
- (or (and (or def (fboundp (car form))) ; might be a subr or autoload.
- (not (memq (car form) byte-compile-noruntime-functions)))
- (eq (car form) byte-compile-current-form) ; ## This doesn't work
- ; with recursion.
- ;; It's a currently-undefined function.
- ;; Remember number of args in call.
- (let ((cons (assq (car form) byte-compile-unresolved-functions))
- (n (length (cdr form))))
- (if cons
- (or (memq n (cdr cons))
- (push n (cdr cons)))
- (push (list (car form) n)
- byte-compile-unresolved-functions))))))
+ (byte-compile-function-warn (car form) (length (cdr form)) def)))
(defun byte-compile-format-warn (form)
"Warn if FORM is `format'-like with inconsistent args.
@@ -2960,8 +2964,6 @@ That command is designed for interactive use only" fn))
'(custom-declare-group custom-declare-variable
custom-declare-face))
(byte-compile-nogroup-warn form))
- (when (get (car form) 'byte-obsolete-info)
- (byte-compile-warn-obsolete (car form)))
(byte-compile-callargs-warn form))
(if byte-compile-generate-call-tree
(byte-compile-annotate-call-tree form))
@@ -3573,24 +3575,7 @@ discarding."
(let ((f (nth 1 form)))
(when (and (symbolp f)
(byte-compile-warning-enabled-p 'callargs))
- (when (get f 'byte-obsolete-info)
- (byte-compile-warn-obsolete (car form)))
-
- ;; Check to see if the function will be available at runtime
- ;; and/or remember its arity if it's unknown.
- (or (and (or (fboundp f) ; Might be a subr or autoload.
- (byte-compile-fdefinition (car form) nil))
- (not (memq f byte-compile-noruntime-functions)))
- (eq f byte-compile-current-form) ; ## This doesn't work
- ; with recursion.
- ;; It's a currently-undefined function.
- ;; Remember number of args in call.
- (let ((cons (assq f byte-compile-unresolved-functions)))
- (if cons
- (or (memq t (cdr cons))
- (push t (cdr cons)))
- (push (list f t)
- byte-compile-unresolved-functions)))))
+ (byte-compile-function-warn f t (byte-compile-fdefinition f nil)))
(byte-compile-constant (if (eq 'lambda (car-safe f))
(byte-compile-lambda f)