unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Jianbin Kang <kjbmail@gmail.com>
Cc: Alan Mackenzie <acm@muc.de>, 47468@debbugs.gnu.org
Subject: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function.
Date: Wed, 12 May 2021 23:57:24 +0200	[thread overview]
Message-ID: <87r1ibsji3.fsf@gnus.org> (raw)
In-Reply-To: <CAF8raN45MvcKAq0YCHFf6jmng_AG=6ErSmD_hqe38q9SQTuxdA@mail.gmail.com> (Jianbin Kang's message of "Mon, 29 Mar 2021 20:47:52 +0800")

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

Jianbin Kang <kjbmail@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:


[-- Attachment #2: Type: image/png, Size: 25838 bytes --]

[-- Attachment #3: Type: text/plain, Size: 245 bytes --]


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

  reply	other threads:[~2021-05-12 21:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:47 bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function Jianbin Kang
2021-05-12 21:57 ` Lars Ingebrigtsen [this message]
2021-05-15 14:57 ` Alan Mackenzie
2021-08-15 19:51   ` Alan Mackenzie
2021-05-19 20:49 ` Vladimir Lichevsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1ibsji3.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=47468@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=kjbmail@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).