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

Previous Next

Package: emacs;

Reported by: Jianbin Kang <kjbmail <at> gmail.com>

Date: Mon, 29 Mar 2021 14:46:02 UTC

Severity: normal

Found in version 27.1

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

Bug is archived. No further changes may be made.

Full log


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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jianbin Kang <kjbmail <at> gmail.com>
Cc: Alan Mackenzie <acm <at> muc.de>, 47468 <at> debbugs.gnu.org
Subject: Re: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++
 lambda function.
Date: Wed, 12 May 2021 23:57:24 +0200
[Message part 1 (text/plain, inline)]
Jianbin Kang <kjbmail <at> gmail.com> 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:

[Message part 2 (image/png, inline)]
[Message part 3 (text/plain, inline)]
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

This bug report was last modified 3 years and 337 days ago.

Previous Next


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