Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang not diagnosing generic lambda with identifier in capture matching declarator-id of template parameter #61105

Closed
shafik opened this issue Mar 1, 2023 · 2 comments
Assignees
Labels
accepts-invalid clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party

Comments

@shafik
Copy link
Collaborator

shafik commented Mar 1, 2023

Given the following:

void f() {
  auto h = [y = 0]<typename y>(y) { return 0; };
}

clang should diagnose this since it is ill-formed, we can see this from expr.prim.lambda.capture p5 which says:

If an identifier in a capture appears as the declarator-id of a parameter of the lambda-declarator's parameter-declaration-clause or as the name of a template parameter of the lambda-expression's template-parameter-list, the program is ill-formed.

and also has the following example:

void f() {
  int x = 0;
  auto g = [x](int x) { return 0; };    // error: parameter and [capture](https://eel.is/c++draft/expr.prim.lambda#nt:capture) have the same name
  auto h = [y = 0]<typename y>(y) { return 0; };    // error: template parameter and [capture](https://eel.is/c++draft/expr.prim.lambda#nt:capture)
                                                    // have the same name
}
@shafik shafik added clang:frontend Language frontend issues, e.g. anything involving "Sema" accepts-invalid confirmed Verified by a second party labels Mar 1, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Mar 1, 2023

@llvm/issue-subscribers-clang-frontend

@Fznamznon Fznamznon self-assigned this Apr 17, 2023
@Fznamznon
Copy link
Contributor

https://reviews.llvm.org/D148712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepts-invalid clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

3 participants