comparison lisp/emacs-lisp/bytecomp.el @ 46657:04d87f195cd1

(byte-compile-cl-functions): New variable. (byte-compile-cl-warn): Use that variable. (byte-compile-find-cl-functions): New function. (displaying-byte-compile-warnings): Call byte-compile-find-cl-functions.
author Richard M. Stallman <rms@gnu.org>
date Wed, 24 Jul 2002 03:58:02 +0000
parents a7eed458393f
children 68c134e00c87
comparison
equal deleted inserted replaced
46656:ac53ae45c502 46657:04d87f195cd1
8 ;; Maintainer: FSF 8 ;; Maintainer: FSF
9 ;; Keywords: lisp 9 ;; Keywords: lisp
10 10
11 ;;; This version incorporates changes up to version 2.10 of the 11 ;;; This version incorporates changes up to version 2.10 of the
12 ;;; Zawinski-Furuseth compiler. 12 ;;; Zawinski-Furuseth compiler.
13 (defconst byte-compile-version "$Revision: 2.102 $") 13 (defconst byte-compile-version "$Revision: 2.106 $")
14 14
15 ;; This file is part of GNU Emacs. 15 ;; This file is part of GNU Emacs.
16 16
17 ;; GNU Emacs is free software; you can redistribute it and/or modify 17 ;; GNU Emacs is free software; you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by 18 ;; it under the terms of the GNU General Public License as published by
955 955
956 ;; Log a message STRING in *Compile-Log*. 956 ;; Log a message STRING in *Compile-Log*.
957 ;; Also log the current function and file if not already done. 957 ;; Also log the current function and file if not already done.
958 (defun byte-compile-log-warning (string &optional fill level) 958 (defun byte-compile-log-warning (string &optional fill level)
959 (let ((warning-prefix-function 'byte-compile-warning-prefix) 959 (let ((warning-prefix-function 'byte-compile-warning-prefix)
960 (warning-group-format "")
960 (warning-fill-prefix (if fill " "))) 961 (warning-fill-prefix (if fill " ")))
961 (display-warning 'bytecomp string level "*Compile-Log*"))) 962 (display-warning 'bytecomp string level "*Compile-Log*")))
962 963
963 (defun byte-compile-warn (format &rest args) 964 (defun byte-compile-warn (format &rest args)
964 "Issue a byte compiler warning; use (format FORMAT ARGS...) for message." 965 "Issue a byte compiler warning; use (format FORMAT ARGS...) for message."
1199 1200
1200 (setq byte-compile-unresolved-functions 1201 (setq byte-compile-unresolved-functions
1201 (delq calls byte-compile-unresolved-functions))))) 1202 (delq calls byte-compile-unresolved-functions)))))
1202 ))) 1203 )))
1203 1204
1205 (defvar byte-compile-cl-functions nil
1206 "List of functions defined in CL.")
1207
1208 (defun byte-compile-find-cl-functions ()
1209 (unless byte-compile-cl-functions
1210 (dolist (elt load-history)
1211 (when (string-match "^cl\\>" (car elt))
1212 (setq byte-compile-cl-functions
1213 (append byte-compile-cl-functions
1214 (cdr elt)))))
1215 (let ((tail byte-compile-cl-functions))
1216 (while tail
1217 (if (and (consp (car tail))
1218 (eq (car (car tail)) 'autoload))
1219 (setcar tail (cdr (car tail))))
1220 (setq tail (cdr tail))))))
1221
1204 (defun byte-compile-cl-warn (form) 1222 (defun byte-compile-cl-warn (form)
1205 "Warn if FORM is a call of a function from the CL package." 1223 "Warn if FORM is a call of a function from the CL package."
1206 (let* ((func (car-safe form)) 1224 (let ((func (car-safe form)))
1207 (library 1225 (if (and byte-compile-cl-functions
1208 (if func 1226 (memq func byte-compile-cl-functions)
1209 (cond ((eq (car-safe func) 'autoload)
1210 (nth 1 func))
1211 ((symbol-file func))))))
1212 (if (and library
1213 (string-match "^cl\\>" library)
1214 ;; Aliases which won't have been expended at this point. 1227 ;; Aliases which won't have been expended at this point.
1215 ;; These aren't all aliases of subrs, so not trivial to 1228 ;; These aren't all aliases of subrs, so not trivial to
1216 ;; avoid hardwiring the list. 1229 ;; avoid hardwiring the list.
1217 (not (memq func 1230 (not (memq func
1218 '(cl-block-wrapper cl-block-throw 1231 '(cl-block-wrapper cl-block-throw
1219 multiple-value-call nth-value 1232 multiple-value-call nth-value
1220 copy-seq first second rest endp cl-member)))) 1233 copy-seq first second rest endp cl-member
1234 ;; This is sometimes defined in CL
1235 ;; but that redefines a standard function,
1236 ;; so don't warn about it.
1237 macroexpand))))
1221 (byte-compile-warn "Function `%s' from cl package called at runtime" 1238 (byte-compile-warn "Function `%s' from cl package called at runtime"
1222 func))) 1239 func)))
1223 form) 1240 form)
1224 1241
1225 (defun byte-compile-print-syms (str1 strn syms) 1242 (defun byte-compile-print-syms (str1 strn syms)
1315 1332
1316 (defmacro displaying-byte-compile-warnings (&rest body) 1333 (defmacro displaying-byte-compile-warnings (&rest body)
1317 `(let (warning-series) 1334 `(let (warning-series)
1318 ;; Log the file name. Record position of that text. 1335 ;; Log the file name. Record position of that text.
1319 (setq warning-series (byte-compile-log-file)) 1336 (setq warning-series (byte-compile-log-file))
1337 (byte-compile-find-cl-functions)
1320 (let ((--displaying-byte-compile-warnings-fn (lambda () 1338 (let ((--displaying-byte-compile-warnings-fn (lambda ()
1321 ,@body))) 1339 ,@body)))
1322 (if byte-compile-debug 1340 (if byte-compile-debug
1323 (funcall --displaying-byte-compile-warnings-fn) 1341 (funcall --displaying-byte-compile-warnings-fn)
1324 (condition-case error-info 1342 (condition-case error-info