summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/bytecomp.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2015-05-05 20:13:10 -0700
committerGlenn Morris <rgm@gnu.org>2015-05-05 20:13:10 -0700
commit276f5d9e108378e13afd26b412526fc57a1f0032 (patch)
treee199e374b5176ca7ac311d4ba9d6ea1a40539e6b /lisp/emacs-lisp/bytecomp.el
parent754fdb1280dfe56a0b94b20c1d7ab0fb5b5615d1 (diff)
downloademacs-276f5d9e108378e13afd26b412526fc57a1f0032.tar.gz
Minor declare-function improvement
* lisp/emacs-lisp/bytecomp.el (byte-compile-macroexpand-declare-function): Handle declarations after calls. (Bug#20509)
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r--lisp/emacs-lisp/bytecomp.el16
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index f0d2ee48ed2..67744c69b14 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2920,11 +2920,17 @@ for symbols generated by the byte compiler itself."
;; Special macro-expander used during byte-compilation.
(defun byte-compile-macroexpand-declare-function (fn file &rest args)
- (push (cons fn
- (if (and (consp args) (listp (car args)))
- (list 'declared (car args))
- t)) ; Arglist not specified.
- byte-compile-function-environment)
+ (let ((gotargs (and (consp args) (listp (car args))))
+ (unresolved (assq fn byte-compile-unresolved-functions)))
+ (when unresolved ; function was called before declaration
+ (if (and gotargs (byte-compile-warning-enabled-p 'callargs))
+ (byte-compile-arglist-warn fn (car args) nil)
+ (setq byte-compile-unresolved-functions
+ (delq unresolved byte-compile-unresolved-functions))))
+ (push (cons fn (if gotargs
+ (list 'declared (car args))
+ t)) ; Arglist not specified.
+ byte-compile-function-environment))
;; We are stating that it _will_ be defined at runtime.
(setq byte-compile-noruntime-functions
(delq fn byte-compile-noruntime-functions))