GNU bug report logs - #73182
CC Mode 5.35.2 (C++//l); 'enum' and 'enum class' appear to not get parsed correctly for indentation

Previous Next

Package: cc-mode;

Reported by: Arsen Arsenović <arsen <at> aarsen.me>

Date: Wed, 11 Sep 2024 18:53:01 UTC

Severity: normal

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Arsen Arsenović <arsen <at> aarsen.me>
Cc: acm <at> muc.de, 73182 <at> debbugs.gnu.org
Subject: bug#73182: CC Mode 5.35.2 (C++//l); 'enum' and 'enum class' appear to not get parsed correctly for indentation
Date: Mon, 16 Sep 2024 11:45:00 +0000
Hello, Arsen.

Thanks for taking the trouble to raise this bug report last Wednesday.

On Wed, Sep 11, 2024 at 20:52:15 +0200, Arsen Arsenović via CC-Mode-help wrote:
> Package: cc-mode

> <#secure method=pgpmime mode=sign>
> Package: cc-mode

> Hi again,

> CC-mode appears to misindent enum and enum class:

>   enum asda
>     {
>       asd
>     };
  
>   enum class asasdas
>     {
>       asda
>     };

Yes.

> These should be indented same as struct per
> https://www.gnu.org/prep/standards/html_node/Formatting.html#index-enum-types_002c-formatting
> (well, enum class isn't mentioned, but I see no reason to act different,
> and GCC appears to do this, so it'd be convenient to keep struct-like
> formatting).

Yes.

> When using C-c C-s, it appears that C and C++ mode do not even recognize
> enum as a class-open, instead doing brace-list-open.

Yes.  This bug has come up at least once before, on 19 February 2014, in a
post to bug-cc-mode <at> gnu.org from Xue Fuqiao, Subject: CC Mode 5.32.5
(C/l); The indentation of `enum' of the default `gnu' style is wrong?
After having considered the matter for some time, I answered on 3 March
2014 as follows:

    Even though there's a bug, it's been there for a _very_ long time
    (since before 1997), such a long time that it would cause chaos if
    it were to be fixed.  You can see many examples of this wrong enum
    indentation all through the Emacs C source, and probably throughout
    the entire GNU project.

    If this bug were to be fixed, inconsistent (even if correct)
    indentation would start creeping into thousands of files.  I think
    it's best left as it is, unsatisfactory though that be.

At the time, I opened a thread on emacs-devel, asking what other people
thought about the bug (Date: 3 March 2014, Subject: The indentation of
`enum' in the default `gnu' CC Mode style is wrong.)  Only one person
responded, Paul Eggert, saying he would be in favour of fixing the bug.

Ten years later, now, I still think that was the right decision to make,
and that the bug should remain unfixed.  If you have nothing against it,
I will close this bug as won't fix.

Sorry about this.

> Emacs  : GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0)
>  of 2024-08-31
> Package: CC Mode 5.35.2 (C++//l)
> Buffer Style: gnu
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties category-properties 1-bit)

[ .... ]

> -- 
> Arsen Arsenović

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 298 days ago.

Previous Next


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