blob: 80ae67a97c03a5db4665d638dbb5bc2a7d353aca [file] [log] [blame]
David Blaikie15a430a2011-12-04 05:04:18 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
3struct global {
4};
5
6namespace PR10127 {
7 struct outer {
8 struct middle {
9 struct inner {
10 int func();
11 int i;
12 };
13 struct inner2 {
14 };
15 struct inner3 {
16 };
17 int mfunc();
18 };
19 typedef int td_int;
20 };
21
22 struct str {
23 operator decltype(outer::middle::inner()) ();
24 operator decltype(outer::middle())::inner2 ();
25 operator decltype(outer())::middle::inner3 ();
26 str(int (decltype(outer::middle::inner())::*n)(),
27 int (decltype(outer::middle())::inner::*o)(),
28 int (decltype(outer())::middle::inner::*p)());
29 };
30
31 int decltype(outer::middle())::inner::func() {
32 return 0;
33 }
34
35 decltype(outer::middle::inner()) a;
36 void scope() {
37 a.decltype(outer::middle())::mfunc(); // expected-error{{'PR10127::outer::middle::mfunc' is not a member of class 'decltype(outer::middle::inner())'}}
38 a.decltype(outer::middle::inner())::func();
39 a.decltype(outer::middle())::inner::func();
40 a.decltype(outer())::middle::inner::func();
41
42 a.decltype(outer())::middle::inner::~inner();
43
44 decltype(outer())::middle::inner().func();
45 }
46 decltype(outer::middle())::inner b;
47 decltype(outer())::middle::inner c;
48 decltype(outer())::fail d; // expected-error{{no type named 'fail' in 'PR10127::outer'}}
49 decltype(outer())::fail::inner e; // expected-error{{no member named 'fail' in 'PR10127::outer'}}
50 decltype()::fail f; // expected-error{{expected expression}}
51 decltype()::middle::fail g; // expected-error{{expected expression}}
52
53 decltype(int()) h;
54 decltype(int())::PR10127::outer i; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
55 decltype(int())::global j; // expected-error{{'decltype(int())' (aka 'int') is not a class, namespace, or scoped enumeration}}
56
57 outer::middle k = decltype(outer())::middle();
58 outer::middle::inner l = decltype(outer())::middle::inner();
59
60 template<typename T>
61 struct templ {
62 typename decltype(T())::middle::inner x; // expected-error{{type 'decltype(int())' (aka 'int') cannot be used prior to '::' because it has no members}}
63 };
64
65 template class templ<int>; // expected-note{{in instantiation of template class 'PR10127::templ<int>' requested here}}
66 template class templ<outer>;
67
68 enum class foo {
69 bar,
70 baz
71 };
72
73 foo m = decltype(foo::bar)::baz;
74
75 enum E {
76 };
77 struct bar {
78 enum E : decltype(outer())::td_int(4);
79 enum F : decltype(outer())::td_int;
80 enum G : decltype; // expected-error{{expected '(' after 'decltype'}}
81 };
82}