xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2 
3 struct S {
4   S *p = this; // ok
5   decltype(this) q; // expected-error {{invalid use of 'this' outside of a non-static member function}}
6 
7   int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a non-static member function}}
8   int sz = sizeof(this); // ok
9 
10   typedef auto f() -> decltype(this); // expected-error {{invalid use of 'this' outside of a non-static member function}}
11 };
12 
13 namespace CaptureThis {
14   struct X {
15     int n = 10;
__anonfe88df130102CaptureThis::X16     int m = [&]{return n + 1; }();
__anonfe88df130202CaptureThis::X17     int o = [&]{return this->m + 1; }();
__anonfe88df130402(int x) 18     int p = [&]{return [&](int x) { return this->m + x;}(o); }();
19   };
20 
21   X x;
22 }
23