Subject: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function.

From: Lars Ingebrigtsen <[email-masked]>
Date: Wed, 12 May 2021 23:57:24 +0200

Jianbin Kang <[email-masked]> writes:

> int main(int argc, char *argv[])
> {
>     PP A = { "Jim" };
>     PP *a = &A;
>
>     print(A.name, [](const char *name) {
>         printf("%s\n", name);           // Syntactic ((inlambda) ... 
>     });
>     print(a->name, [=](const char *name) {
>             printf("%s\n", name);       // Syntactic((arglist-cont-nonempty ...
>         });
>
>     return 0;

[...]

> If I put cursor in lambda body of first print call, and run 'c-show-syntactic-information',
> it shows 'Syntactic analysis: ((inlambda) (defun-block-intro 258))', which is correct and
> I get good indentation.
>
> But in second print call, I get 'Syntactic analysis:
> ((arglist-cont-nonempty 337 342) (statement-block-intro 337))' and the
> indentation is bad.

I can reproduce this in Emacs 28, too.  Poking around a bit, it seems
like it's getting tripped up by the "a->name" bit?  Changing that to
a.name (for instance) makes it recognise the second form as a lambda
function...

However, the first form is indented wrong for me in Emacs 28:

This is indented correctly in Emacs 27.1, so it seems like this has
regressed between Emacs 27.1 and Emacs 28.

I've added Alan to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no