summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2002-10-14 01:33:40 +0000
committerRichard M. Stallman <rms@gnu.org>2002-10-14 01:33:40 +0000
commit8c26d7b356a8674c7bf052bcb829a183cc929cc9 (patch)
tree151b295d099130433eb6ed516add246b18b289f1 /lisp/emacs-lisp
parent7dab57b625b1de0e88bf3fab56665e5f05f779ad (diff)
downloademacs-8c26d7b356a8674c7bf052bcb829a183cc929cc9.tar.gz
emacs-8c26d7b356a8674c7bf052bcb829a183cc929cc9.tar.bz2
emacs-8c26d7b356a8674c7bf052bcb829a183cc929cc9.zip
(byte-optimize-form-code-walker): Treat `ignore' specially--prevent
warnings about functions called for effect, in its args. Don't warn when `pop' is used for effect.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/byte-opt.el21
1 files changed, 20 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index 5594b918b37..af68b7c919a 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -501,6 +501,13 @@
(cons (byte-optimize-form (nth 1 form) nil)
(cdr (cdr form)))))
+ ((eq fn 'ignore)
+ ;; Don't treat the args to `ignore' as being
+ ;; computed for effect. We want to avoid the warnings
+ ;; that might occur if they were treated that way.
+ ;; However, don't actually bother calling `ignore'.
+ `(prog1 nil . ,(mapcar 'byte-optimize-form (cdr form))))
+
;; If optimization is on, this is the only place that macros are
;; expanded. If optimization is off, then macroexpansion happens
;; in byte-compile-form. Otherwise, the macros are already expanded
@@ -526,9 +533,21 @@
((and for-effect (setq tmp (get fn 'side-effect-free))
(or byte-compile-delete-errors
(eq tmp 'error-free)
+ ;; Detect the expansion of (pop foo).
+ ;; There is no need to compile the call to `car' there.
+ (and (eq fn 'car)
+ (eq (car-safe (cadr form)) 'prog1)
+ (let ((var (cadr (cadr form)))
+ (last (nth 2 (cadr form))))
+ (and (symbolp var)
+ (null (nthcdr 3 (cadr form)))
+ (eq (car-safe last) 'setq)
+ (eq (cadr last) var)
+ (eq (car-safe (nth 2 last)) 'cdr)
+ (eq (cadr (nth 2 last)) var))))
(progn
(byte-compile-warn "`%s' called for effect"
- (prin1-to-string form))
+ (prin1-to-string (car form)))
nil)))
(byte-compile-log " %s called for effect; deleted" fn)
;; appending a nil here might not be necessary, but it can't hurt.