p4-0x.cpp revision a85cf39786fffd6860a940523be01eb02a4935c0
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3struct 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
11namespace CaptureThis {
12  struct X {
13    int n = 10;
14    int m = [&]{return n + 1; }();
15    int o = [&]{return this->m + 1; }();
16    int p = [&]{return [&](int x) { return this->m + x;}(o); }();
17  };
18
19  X x;
20}
21