bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jianbin Kang
Subject: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function.
Date: Mon, 29 Mar 2021 20:47:52 +0800


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'.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]