Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / g++.dg / cpp0x / lambda / lambda-field-names.C
blob1c5cfdbd8e0e23609bfa6f1bd0822fe5442f3724
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.
5 // { dg-do compile { target c++11 } }
7 template <class T>
8 struct A: public T
10   A(T t): T(t) { }
11   int f() { return this->i; }   // { dg-error "" "no member named i" }
14 int main()
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();