From: storm@cua.dk (Kim F. Storm)
To: Alan Mackenzie <acm@muc.de>
Cc: Chong Yidong <cyd@stupidchicken.com>,
rms@gnu.org, Markus Triska <markus.triska@gmx.at>,
emacs-devel@gnu.org
Subject: Re: Nonsensical byte compiler warning.
Date: Sun, 08 Apr 2007 03:21:07 +0200 [thread overview]
Message-ID: <m3lkh3zmnw.fsf@kfs-l.imdomain.dk> (raw)
In-Reply-To: <20070404212752.GA2717@muc.de> (Alan Mackenzie's message of "4 Apr 2007 22\:08\:55 +0200")
Alan Mackenzie <acm@muc.de> 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 <markus.triska@gmx.at> 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 <storm@cua.dk> http://www.cua.dk
next prev parent reply other threads:[~2007-04-08 1:21 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-01 17:14 Nonsensical byte compiler warning David Kastrup
2007-04-01 18:10 ` Chong Yidong
2007-04-01 20:57 ` Alan Mackenzie
2007-04-02 12:29 ` Richard Stallman
2007-04-04 4:48 ` Markus Triska
2007-04-04 6:15 ` David Kastrup
2007-04-04 8:19 ` Markus Triska
2007-04-04 8:46 ` David Kastrup
2007-04-04 9:50 ` Markus Triska
2007-04-04 10:17 ` David Kastrup
2007-04-04 12:35 ` Markus Triska
2007-04-04 18:25 ` Markus Triska
2007-04-04 22:13 ` David Kastrup
2007-04-05 6:52 ` Richard Stallman
2007-04-05 7:55 ` Markus Triska
2007-04-06 12:56 ` Richard Stallman
2007-04-06 15:11 ` Chong Yidong
2007-04-08 20:47 ` Markus Triska
2007-04-09 15:42 ` Richard Stallman
2007-04-10 3:53 ` Glenn Morris
2007-04-10 17:27 ` Markus Triska
2007-04-11 4:00 ` Glenn Morris
2007-04-05 18:01 ` Chong Yidong
2007-04-04 20:08 ` Alan Mackenzie
2007-04-04 21:45 ` Markus Triska
2007-04-04 22:11 ` Chong Yidong
2007-04-05 5:44 ` Markus Triska
2007-04-08 1:21 ` Kim F. Storm [this message]
2007-04-08 11:27 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3lkh3zmnw.fsf@kfs-l.imdomain.dk \
--to=storm@cua.dk \
--cc=acm@muc.de \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
--cc=markus.triska@gmx.at \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).