GNU bug report logs - #72695
CC Mode 5.35.2 (C++//l); c++-mode misindents 'if constexpr' inside lambdas

Previous Next

Package: cc-mode;

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

Date: Sun, 18 Aug 2024 09:52:02 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, 72695 <at> debbugs.gnu.org
Subject: bug#72695: CC Mode 5.35.2 (C++//l); c++-mode misindents 'if constexpr' inside lambdas
Date: Fri, 27 Sep 2024 22:38:07 +0000
Hello, Arsen.

On Fri, Sep 27, 2024 at 23:54:57 +0200, Arsen Arsenović wrote:
> Hi Alan,

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

> > I've now committed a slightly different patch, after noticing and fixing
> > another bug.

> > The bug was that in code like

> > 1 template <typename T>
> > 2 requires requires (T x)
> > 3 { x + x; }
> > 4 T add(T a, T b)
> > 5 {
> > 6    return a + b;
> > 7 }

> > , L4, a topmost-intro-cont used to be anchored on the previous
> > topmost-intro-cont line, L2, whereas it should be anchored on the
> > topmost-intro, L1.

> > I've now corrected this.

> Ah!  Good catch.

> > I didn't send you yet another patch with request for testing, because
> > I've done that rather a lot of late, and I'm confident about the patch.

> > I haven't yet closed the bug, just in case you wanted to do some final,
> > final testing on the committed version.  Please let me know what you feel
> > about that, so that I can finally close this bug.

So, can I close bug#72695 now?

> I'm not sure this is a bug but it is something I noticed by accident:

>       (std::visit
>        ([] <typename T>
>        	(const T& data)
> 	{
>         }));

> ... the { is not an inline-open, but an arglist-cont-nonempty (though,
> to be clear, the body is indented okay; I've elided it from the example
> above for that reason).

That is a bug, yes, but a different bug.  Could I ask you to raise a new
Emacs bug report for it, please?

I think it will require some effort to solve, since it involves "function
type" constructs inside parentheses, which I think was something new to
CC Mode with C++20 (but I'm not sure).  Rather than just relying on the
context of the outer (, c-guess-basic-syntax will have to examine the
contents of (...) to get better analysis.

> Same goes for the (const T& data), which doesn't get indented the same
> as a 'standalone' lambda, but it does indent the same as one saved into
> a variable:

>   []
>     ()
>   {
>   };
>   auto x =
>     []
>     ()
>     {
>     };
>   auto x =
>     ([]
>      ()
>     {
>     });

> I do not know whether this is correct.

Neither do I, this late at night.  ;-)  I'll have a look at all these
examples tomorrow.

> But thank you again for working on this!

A pleasure!

> Have a lovely day.
> -- 
> Arsen Arsenović

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 294 days ago.

Previous Next


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