From: Alan Mackenzie <acm@muc.de>
To: 23775@debbugs.gnu.org
Cc: Rolf Ade <rolf@pointsman.de>
Subject: bug#23775: 25.0.95.2; c-mode: Incorrect indentation and function bundery detection
Date: 16 Jun 2016 09:18:39 -0000 [thread overview]
Message-ID: <20160616091839.6925.qmail__31295.7325172194$1466070036$gmane$org@mail.muc.de> (raw)
In-Reply-To: <mailman.1576.1466039228.1216.bug-gnu-emacs@gnu.org>
Hello, Rolf.
In article <mailman.1576.1466039228.1216.bug-gnu-emacs@gnu.org> you wrote:
> emacs -Q
> Open some empty buffer foo.c and put it into c-mode if already is
> (M-x c-mdoe). Insert this C code into it:
> #define foo
> int main (void) {
> int a=0;
> int b=0;
> #ifdef foo
> if (a==0) {
> #else
> if (b==0) {
> #endif
> return 0;
> }
> }
> I've inserted it here as emacs -Q indents it, this is the indentation
> part of the report.
> Place the point at the beginning of function foo, then call
> c-end-of-defun, C-M-e by default in emacs -Q. Bell rings, point is
> before the last charater of the first line of main, here:
> int main (void) _P_{
> (which is clearly not the end of the function) and prompts me in the
> mini-buffer: "forward-sexp: Scan error: "Unbalanced parentheses", 29,
> 133"
> However well advised such code is, gcc foo.c just compilies.
Yes, this has come up before. Unbalanced braces in preprocessor
statements[*] are horrendously difficult to parse - what should be done, for
example, when two arms of a #if construct have different numbers of
braces?
[*] ...by which I mean the part inside a particular arm of a preprocessor
conditional has unbalanced braces.
I tried once before to solve this problem, but didn't get very far. What
was obvious, at the time, was that a solution would slow CC Mode down,
possibly quite a bit.
So, we've collectively decided that this bug, although real, won't be
fixed. The best advice we can give is to arrange the C code such that
unbalanced braces in #if arms don't happen.
Sorry.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2016-06-16 9:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 1:05 bug#23775: 25.0.95.2; c-mode: Incorrect indentation and function bundery detection Rolf Ade
2016-06-16 1:34 ` Noam Postavsky
[not found] ` <mailman.1576.1466039228.1216.bug-gnu-emacs@gnu.org>
2016-06-16 9:18 ` Alan Mackenzie [this message]
[not found] <20160616091839.6925.qmail@mail.muc.de>
2016-06-21 23:16 ` Rolf Ade
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='20160616091839.6925.qmail__31295.7325172194$1466070036$gmane$org@mail.muc.de' \
--to=acm@muc.de \
--cc=23775@debbugs.gnu.org \
--cc=rolf@pointsman.de \
/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.