GNU bug report logs - #23775
25.0.95.2; c-mode: Incorrect indentation and function bundery detection

Previous Next

Packages: emacs, cc-mode;

Reported by: Rolf Ade <rolf <at> pointsman.de>

Date: Thu, 16 Jun 2016 01:07:02 UTC

Severity: minor

Tags: wontfix

Found in version 25.0.95.2

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 23775 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: 23775 <at> debbugs.gnu.org
Cc: Rolf Ade <rolf <at> pointsman.de>
Subject: Re: bug#23775: 25.0.95.2;
 c-mode: Incorrect indentation and function bundery detection
Date: 16 Jun 2016 09:18:39 -0000
Hello, Rolf.
In article <mailman.1576.1466039228.1216.bug-gnu-emacs <at> 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).





This bug report was last modified 9 years and 41 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.