(byte-compile-recurse-toplevel
(macroexp-progn body)
(lambda (form)
- (setf result
- (byte-compile-eval
- (byte-compile-top-level
- (byte-compile-preprocess form))))))
+ (let ((byte-compile-unresolved-functions
+ byte-compile-unresolved-functions)
+ (byte-compile-new-defuns
+ byte-compile-new-defuns))
+ (setf result
+ (byte-compile-eval
+ (byte-compile-top-level
+ (byte-compile-preprocess form)))))))
(list 'quote result))))
(eval-and-compile . ,(lambda (&rest body)
(byte-compile-recurse-toplevel
Used for warnings about calling a function that is defined during compilation
but won't necessarily be defined when the compiled file is loaded.")
+(defvar byte-compile-new-defuns nil
+ "List of functions defined for use at runtime.
+This variable is used to qualify `byte-compile-noruntime-functions' when
+outputting warnings about functions not being defined at runtime.")
+
;; Variables for lexical binding
(defvar byte-compile--lexical-environment nil
"The current lexical environment.")
;; Separate the functions that will not be available at runtime
;; from the truly unresolved ones.
(dolist (f byte-compile-unresolved-functions)
- (setq f (car f))
- (if (fboundp f) (push f noruntime) (push f unresolved)))
+ (setq f (car f))
+ (when (not (memq f byte-compile-new-defuns))
+ (if (fboundp f) (push f noruntime) (push f unresolved))))
;; Complain about the no-run-time functions
(byte-compile-print-syms
"the function `%s' might not be defined at runtime."
;; compiled. A: Yes! b-c-u-f might contain dross from a
;; previous byte-compile.
(setq byte-compile-unresolved-functions nil)
+ (setq byte-compile-noruntime-functions nil)
+ (setq byte-compile-new-defuns nil)
;; Compile the forms from the input buffer.
(while (progn
(defun byte-compile-file-form-require (form)
(let ((args (mapcar 'eval (cdr form)))
(hist-orig load-history)
- hist-new)
+ hist-new prov-cons)
(apply 'require args)
+
+ ;; Record the functions defined by the require in `byte-compille-new-defuns'.
+ (setq hist-new load-history)
+ (setq prov-cons (cons 'provide (car args)))
+ (while (and hist-new
+ (not (member prov-cons (car hist-new))))
+ (setq hist-new (cdr hist-new)))
+ (when hist-new
+ (dolist (x (car hist-new))
+ (when (and (consp x)
+ (memq (car x) '(defun t)))
+ (push (cdr x) byte-compile-new-defuns))))
+
(when (byte-compile-warning-enabled-p 'cl-functions)
;; Detect (require 'cl) in a way that works even if cl is already loaded.
(if (member (car args) '("cl" cl))
(byte-compile-current-form name)) ; For warnings.
(byte-compile-set-symbol-position name)
+ (push name byte-compile-new-defuns)
;; When a function or macro is defined, add it to the call tree so that
;; we can tell when functions are not used.
(if byte-compile-generate-call-tree