all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jianbin Kang <kjbmail@gmail.com>
To: 47468@debbugs.gnu.org
Subject: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function.
Date: Mon, 29 Mar 2021 20:47:52 +0800	[thread overview]
Message-ID: <CAF8raN45MvcKAq0YCHFf6jmng_AG=6ErSmD_hqe38q9SQTuxdA@mail.gmail.com> (raw)

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

The c++ file to reproduce it:
```c++
#include <stdio.h>
#include <functional>

struct PP {
    const char *        name;
};

static void print(const char *name, std::function<void(const char *)> f)
{
    f(name);
}

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.

My emacs version is 27.1. I can reproduce the problem in both Linux and
Windows with 'emacs -Q'.

[-- Attachment #2: Type: text/html, Size: 1320 bytes --]

             reply	other threads:[~2021-03-29 12:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:47 Jianbin Kang [this message]
2021-05-12 21:57 ` bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function Lars Ingebrigtsen
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

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

  git send-email \
    --in-reply-to='CAF8raN45MvcKAq0YCHFf6jmng_AG=6ErSmD_hqe38q9SQTuxdA@mail.gmail.com' \
    --to=kjbmail@gmail.com \
    --cc=47468@debbugs.gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.