]> git.eshelyaron.com Git - emacs.git/commitdiff
Minor declare-function improvement
authorGlenn Morris <rgm@gnu.org>
Wed, 6 May 2015 03:13:10 +0000 (20:13 -0700)
committerGlenn Morris <rgm@gnu.org>
Wed, 6 May 2015 03:13:10 +0000 (20:13 -0700)
* lisp/emacs-lisp/bytecomp.el
(byte-compile-macroexpand-declare-function):
Handle declarations after calls.  (Bug#20509)

lisp/emacs-lisp/bytecomp.el

index f0d2ee48ed29a1cfbe77d8d92fba056130f8ce8b..67744c69b14594f53e323facf3f1a26d3fced137 100644 (file)
@@ -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))