Skip to content

[clang] Clang accepts function attributes on lambdas in the wrong place #125677

@usx95

Description

@usx95
void foo() {
    auto x = [] [[noreturn]] (int msg) { throw; }; // accepted in wrong place.
    auto y = [](int msg) [[noreturn]] { throw; }; // not accepted in the right place
    auto z = [](int) [[clang::annotate_type("foo")]] {};
}

https://godbolt.org/z/sqnWo4v67

The attributes should be accepted after the parameters in the lambda declarator.
https://timsong-cpp.github.io/cppwp/n4868/expr.prim.lambda#nt:lambda-declarator

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"invalidResolved as invalid, i.e. not a buglambdaC++11 lambda expressions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions