Debian Codegraph @

clang/test/SemaCXX/cxx2b-warn-shadow.cpp

raw
1 // RUN: %clang_cc1 -verify -fsyntax-only -std=c++2b -Wshadow-all %s
2
3 namespace GH95707 {
4 struct Foo {
5 int a; // expected-note 2 {{previous declaration is here}}
6
7 void f1(this auto &self, int a) { self.a = a; }
8 void f2(int a) { } // expected-warning {{declaration shadows a field of 'GH95707::Foo'}}
9 void f3() {
10 (void)[&](this auto &self, int a) { }; // expected-warning {{declaration shadows a field of 'GH95707::Foo'}}
11 }
12 };
13 } // namespace GH95707
14
15 namespace GH163731 {
16 struct S1 {
17 int a;
18 void m(this S1 &self) {
19 auto lambda = [](int a) { return a; };
20 }
21 };
22
23 struct S2 {
24 int a;
25 void m(this S2 &self) {
26 int a = 1; // expected-note {{previous declaration is here}}
27 auto lambda = [](int a) { // expected-warning {{declaration shadows a local variable}}
28 return a;
29 };
30 }
31 };
32
33 struct S3 {
34 int a;
35 void m(this S3 &self) {
36 auto lambda = [self](int a) { return a + self.a; };
37 }
38 };
39 }