Skip to content

[Clang] Immediate-escalating expression attributed to wrong lambda #145776

@katzdm

Description

@katzdm

The following should be well-formed, but clang diagnoses:

void runtime_only() { }
consteval void comptime_only() {}

void fn() {
    []() {
        runtime_only();
        [](){ (void) comptime_only; }();
    }();
}

The id-expression that names comptime_only is immediate-escalating. Clang currently attributes that expression to the outer lambda, despite its occurrence within the inner lambda. It seems to me that this stems from the ExpressionEvaluationContext corresponding to the inner lambda being popped after the FunctionScopeInfo corresponding to the same has already been popped. Naively re-sequencing these operations appears to cause other problems (e.g., failing assertions related to ODR-uses in ActOnFinishFunctionBody).

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"lambdaC++11 lambda expressions

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions