Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-field-names.C

raw
1 // "For each entity captured by copy, an unnamed non-static data member is
2 // declared in the closure type" -- test that there isn't a member of the
3 // closure with the same name as the captured variable.
4
5 // { dg-do compile { target c++11 } }
6
7 template <class T>
8 struct A: public T
9 {
10 A(T t): T(t) { }
11 int f() { return this->i; } // { dg-error "" "no member named i" }
12 };
13
14 int main()
15 {
16 int i = 42;
17 auto lam = [i]{ };
18 lam.i = 24; // { dg-error "" "no member named i" }
19 A<decltype(lam)> a(lam);
20 return a.f();
21 }