From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Nonsensical byte compiler warning. Date: Sun, 08 Apr 2007 03:21:07 +0200 Message-ID: References: <85ps6okoe5.fsf@lola.goethe.zz> <87lkhcj791.fsf@stupidchicken.com> <87tzvwvj6c.fsf@gmx.at> <861wj04qcq.fsf@lola.quinscape.zz> <873b3gpn4u.fsf@gmx.at> <20070404212752.GA2717@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1175995340 11266 80.91.229.12 (8 Apr 2007 01:22:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 Apr 2007 01:22:20 +0000 (UTC) Cc: Chong Yidong , rms@gnu.org, Markus Triska , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 08 03:21:32 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HaM5y-0004HW-HO for ged-emacs-devel@m.gmane.org; Sun, 08 Apr 2007 03:21:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HaM9c-0005BO-QE for ged-emacs-devel@m.gmane.org; Sat, 07 Apr 2007 21:25:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HaM9Z-00058X-Bv for emacs-devel@gnu.org; Sat, 07 Apr 2007 21:25:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HaM9Y-00054H-3g for emacs-devel@gnu.org; Sat, 07 Apr 2007 21:25:12 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HaM9X-00053n-Uh for emacs-devel@gnu.org; Sat, 07 Apr 2007 21:25:11 -0400 Original-Received: from pfepc.post.tele.dk ([195.41.46.237]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HaM5r-0006Ro-PZ; Sat, 07 Apr 2007 21:21:24 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx19.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id ED7E88A0002; Sun, 8 Apr 2007 03:21:20 +0200 (CEST) In-Reply-To: <20070404212752.GA2717@muc.de> (Alan Mackenzie's message of "4 Apr 2007 22\:08\:55 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69188 Archived-At: Alan Mackenzie 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 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 http://www.cua.dk