[all-commits] [llvm/llvm-project] 0fb84b: [clang] Diagnose shadowing of lambda's template pa...

Mariya Podchishchaeva via All-commits all-commits at lists.llvm.org
Fri Apr 28 04:27:12 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0fb84bc7fdec1c20c2461e54d5c994939fe5b47f
      https://github.com/llvm/llvm-project/commit/0fb84bc7fdec1c20c2461e54d5c994939fe5b47f
  Author: Mariya Podchishchaeva <mariya.podchishchaeva at intel.com>
  Date:   2023-04-28 (Fri, 28 Apr 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaLambda.cpp
    A clang/test/CXX/expr/expr.prim/expr.prim.lambda/expr.prim.lambda.capture/p5.cpp
    M clang/test/SemaCXX/warn-shadow-in-lambdas.cpp

  Log Message:
  -----------
  [clang] Diagnose shadowing of lambda's template parameter by a capture

expr.prim.lambda.capture p5 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:
```
auto h = [y = 0]<typename y>(y) { return 0; };
```
which now results in
```
error: declaration of 'y' shadows template parameter
  auto l1 = [y = 0]<typename y>(y) { return 0; };
             ^
note: template parameter is declared here
  auto l1 = [y = 0]<typename y>(y) { return 0; };
                             ^
```

Fixes https://github.com/llvm/llvm-project/issues/61105

Reviewed By: shafik, cor3ntin

Differential Revision: https://reviews.llvm.org/D148712




More information about the All-commits mailing list