From: Alan Mackenzie <acm@muc.de>
To: Daniel Colascione <dancol@dancol.org>
Cc: 7918@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#7918: [PATCH] cc-mode: only the first clause of a for-loop should be checked for declarations
Date: Fri, 1 Apr 2016 16:18:19 +0000 [thread overview]
Message-ID: <20160401161819.GA3299@acm.fritz.box> (raw)
In-Reply-To: <56D5D9FB.2060605@dancol.org>
Hello, Daniel.
On Tue, Mar 01, 2016 at 10:05:47AM -0800, Daniel Colascione wrote:
> On 03/01/2016 10:02 AM, Alan Mackenzie wrote:
> > On Fri, Feb 26, 2016 at 04:48:13PM +1030, Lars Ingebrigtsen wrote:
> >> Daniel Colascione <dan.colascione@gmail.com> writes:
> >>> // This code has no variable declarations
> >>> void foo() {
> >>> for (; (DWORD) a * b ;)
> >>> ;
> >>> for (; a * b ;)
> >>> ;
> >>> }
> It's been years since I even thought about that code. If you're up for
> it, I'd rather you supply a separate fix.
OK, here goes:
diff -r f19a4ffb060b cc-fonts.el
--- a/cc-fonts.el Fri Apr 01 12:23:17 2016 +0000
+++ b/cc-fonts.el Fri Apr 01 16:10:57 2016 +0000
@@ -1206,8 +1206,20 @@
'font-lock-keyword-face)
(looking-at c-not-decl-init-keywords))
(and c-macro-with-semi-re
- (looking-at c-macro-with-semi-re))) ; 2008-11-04
- ;; Don't do anything more if we're looking at a keyword that
+ (looking-at c-macro-with-semi-re)) ; 2008-11-04
+ (save-excursion ; A construct after a ; in a `for' statement
+ ; can't be a declaration.
+ (and (c-go-up-list-backward)
+ (eq (char-after) ?\()
+ (progn (c-backward-syntactic-ws)
+ (c-simple-skip-symbol-backward))
+ (looking-at c-paren-stmt-key)
+ (progn (goto-char match-pos)
+ (while (and (eq (char-before) ?\))
+ (c-go-list-backward))
+ (c-backward-syntactic-ws))
+ (eq (char-before) ?\;)))))
+ ;; Don't do anything more if we're looking at something that
;; can't start a declaration.
t
Could you do the usual with this patch, please, then if everything's OK,
I can commit it to the emacs-25 branch. Thanks!
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2016-04-01 16:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-26 6:36 bug#7918: [PATCH] cc-mode: only the first clause of a for-loop should be checked for declarations Daniel Colascione
2016-02-26 6:18 ` Lars Ingebrigtsen
2016-02-26 6:31 ` Daniel Colascione
2016-02-26 6:33 ` Daniel Colascione
2016-03-01 18:02 ` Alan Mackenzie
2016-03-01 18:05 ` Daniel Colascione
2016-04-01 16:18 ` Alan Mackenzie [this message]
2016-04-25 18:04 ` Alan Mackenzie
[not found] ` <handler.7918.D7918.146160769022226.notifdone@debbugs.gnu.org>
2017-06-29 1:06 ` npostavs
2017-07-03 19:09 ` Glenn Morris
2017-07-03 19:46 ` npostavs
2017-07-03 20:18 ` Alan Mackenzie
2017-07-05 15:55 ` Glenn Morris
2017-07-05 20:14 ` Alan Mackenzie
2017-07-06 1:39 ` Glenn Morris
2017-07-07 14:47 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160401161819.GA3299@acm.fritz.box \
--to=acm@muc.de \
--cc=7918@debbugs.gnu.org \
--cc=dancol@dancol.org \
--cc=larsi@gnus.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.