File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -432,6 +432,7 @@ Bug Fixes in This Version
432432- Fixed a failed assertion with empty filename arguments in ``__has_embed ``. (#GH159898)
433433- Fixed a failed assertion with empty filename in ``#embed `` directive. (#GH162951)
434434- Fixed a crash triggered by unterminated ``__has_embed ``. (#GH162953)
435+ - Fixed false-positive shadow diagnostics for lambdas in explicit object member functions. (#GH163731)
435436
436437Bug Fixes to Compiler Builtins
437438^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -8640,6 +8640,11 @@ void Sema::DiagnoseShadowingLambdaDecls(const LambdaScopeInfo *LSI) {
86408640 << Shadow.VD->getDeclName() << /*explicitly*/ 0;
86418641 Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
86428642 } else if (isa<FieldDecl>(ShadowedDecl)) {
8643+ if (CXXMethodDecl *MD =
8644+ dyn_cast<CXXMethodDecl>(getFunctionLevelDeclContext()))
8645+ if (MD->isExplicitObjectMemberFunction())
8646+ continue;
8647+
86438648 Diag(Shadow.VD->getLocation(),
86448649 LSI->isCXXThisCaptured() ? diag::warn_decl_shadow
86458650 : diag::warn_decl_shadow_uncaptured_local)
Original file line number Diff line number Diff line change 33// RUN: %clang_cc1 -std=c++14 -verify=expected,cxx14 -fsyntax-only -Wshadow-all %s
44// RUN: %clang_cc1 -std=c++17 -verify -fsyntax-only -Wshadow-all %s
55// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only -Wshadow-all %s
6+ // RUN: %clang_cc1 -std=c++23 -verify -fsyntax-only -Wshadow-all %s
67
78void foo (int param) { // expected-note 1+ {{previous declaration is here}}
89 int var = 0 ; // expected-note 1+ {{previous declaration is here}}
@@ -268,5 +269,32 @@ int foo() {
268269 }();
269270#endif
270271}
272+ }
273+
274+ #if __cplusplus >= 202302L
275+ namespace GH163731 {
276+ struct S1 {
277+ int a;
278+ void m (this S1 &self) {
279+ auto lambda = [](int a) { return a; };
280+ }
281+ };
282+
283+ struct S2 {
284+ int a;
285+ void m (this S2 &self) {
286+ int a = 1 ; // expected-note {{previous declaration is here}}
287+ auto lambda = [](int a) { // expected-warning {{declaration shadows a local variable}}
288+ return a;
289+ };
290+ }
291+ };
271292
293+ struct S3 {
294+ int a;
295+ void m (this S3 &self) {
296+ auto lambda = [self](int a) { return a + self.a ; };
297+ }
298+ };
272299}
300+ #endif
You can’t perform that action at this time.
0 commit comments