brintos

brintos / llvm-project-archived public Read only

0
0
Text · 943 B · 9ce0c5a Raw
40 lines · cpp
1// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2b -Wshadow-all %s2 3namespace GH95707 {4struct 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 GH9570714 15namespace GH163731 {16struct S1 {17  int a;18  void m(this S1 &self) {19    auto lambda = [](int a) { return a; };20  }21};22 23struct 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 33struct S3 {34  int a;35  void m(this S3 &self) {36    auto lambda = [self](int a) { return a + self.a; };37  }38};39}40