[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Nonsensical byte compiler warning.
From: |
Kim F. Storm |
Subject: |
Re: Nonsensical byte compiler warning. |
Date: |
Sun, 08 Apr 2007 03:21:07 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux) |
Alan Mackenzie <address@hidden> writes:
> But I did get "While compiling c-end-of-defun in file
> /home/acm/cc-mode-5.31.n/cc-cmds.el: ** `(char-after (1- (point)))'
> called for
> effect". Track this down: It's in c-end-of-defun. By commenting out
> bits of
> the function in a binary chop fashion, it's L1625, "(eq (char-before)
> ?\})".
> I can't make head or tail of this. FIXME!!! POSTPONED.
The problem is still not fixed ... The warning is still issued, and
the following post shows why:
Markus Triska <address@hidden> writes:
> No, I think it's already good enough in this case. For example, set
> `byte-optimize-log' to t. The warning is then preceded by:
>
> (char-before) ==> (char-after (1- (point)))
> (if (and (= arg 0) (c-syntactic-skip-backward "^}") (eq (char-after
> ...) 125)) nil) ==> (progn (and (= arg 0) (c-syntactic-skip-backward
> "^}") (eq (char-after ...) 125)) nil)
> eq called for effect; deleted
Looking at the offending code, it is rather obvious why it says eq is
called for effect.
The relevant part of the code looks like this:
(if (< arg 0)
;; Move backwards to the } of a function
(progn
(if (memq where '(at-header outwith-function))
(setq arg (1+ arg)))
(if (< arg 0)
(setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
(when (and (= arg 0)
(c-syntactic-skip-backward "^}")
(eq (char-before) ?\}))
t))
;; Move forward to the } of a function
(if (> arg 0)
(setq arg (c-forward-to-nth-EOF-} arg where))))
Since the value of the surrounding "if" is not used, the value of the
(when ... t) is not used either, and as such it has no purpose to
evaluate the (eq (char-before) ...) part.
So as Chong already suggested, replacing
(when (and (= arg 0)
(c-syntactic-skip-backward "^}")
(eq (char-before) ?\}))
t))
with
(if (= arg 0)
(c-syntactic-skip-backward "^}")))
does the same thing.
Here's the patch:
*** cc-cmds.el 08 Apr 2007 01:47:26 +0200 1.56
--- cc-cmds.el 08 Apr 2007 03:16:14 +0200
***************
*** 1630,1639 ****
(setq arg (1+ arg)))
(if (< arg 0)
(setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
! (when (and (= arg 0)
! (c-syntactic-skip-backward "^}")
! (eq (char-before) ?\}))
! t))
;; Move forward to the } of a function
(if (> arg 0)
--- 1630,1637 ----
(setq arg (1+ arg)))
(if (< arg 0)
(setq arg (c-backward-to-nth-BOF-{ (- arg) where)))
! (if (= arg 0)
! (c-syntactic-skip-backward "^}")))
;; Move forward to the } of a function
(if (> arg 0)
--
Kim F. Storm <address@hidden> http://www.cua.dk
- Re: Nonsensical byte compiler warning., (continued)
- Re: Nonsensical byte compiler warning., Markus Triska, 2007/04/08
- Re: Nonsensical byte compiler warning., Richard Stallman, 2007/04/09
- Re: Nonsensical byte compiler warning., Glenn Morris, 2007/04/09
- Re: Nonsensical byte compiler warning., Markus Triska, 2007/04/10
- Re: Nonsensical byte compiler warning., Glenn Morris, 2007/04/11
- Re: Nonsensical byte compiler warning., Chong Yidong, 2007/04/05
- Re: Nonsensical byte compiler warning., Alan Mackenzie, 2007/04/04
- Re: Nonsensical byte compiler warning., Markus Triska, 2007/04/04
- Re: Nonsensical byte compiler warning., Chong Yidong, 2007/04/04
- Re: Nonsensical byte compiler warning., Markus Triska, 2007/04/05
- Re: Nonsensical byte compiler warning.,
Kim F. Storm <=
- Re: Nonsensical byte compiler warning., Alan Mackenzie, 2007/04/08