instantiate-declref.cpp revision 8e92bf33baa91a8d97cbd4859648af149d5b5e74
1// RUN: clang-cc -fsyntax-only -verify %s 2namespace N { 3 struct Outer { 4 struct Inner { 5 template<typename T> 6 struct InnerTemplate { 7 struct VeryInner { 8 typedef T type; 9 10 static enum K1 { K1Val = sizeof(T) } Kind1; 11 static enum { K2Val = sizeof(T)*2 } Kind2; 12 enum { K3Val = sizeof(T)*2 } Kind3; 13 14 void foo() { 15 K1 k1 = K1Val; 16 Kind1 = K1Val; 17 Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val; 18 Kind3 = K3Val; 19 } 20 21 struct UeberInner { 22 void bar() { 23 K1 k1 = K1Val; 24 Kind1 = K1Val; 25 Outer::Inner::InnerTemplate<type>::VeryInner::Kind2 = K2Val; 26 27 InnerTemplate t; 28 InnerTemplate<type> t2; 29 } 30 }; 31 }; 32 }; 33 }; 34 }; 35} 36 37typedef int INT; 38template struct N::Outer::Inner::InnerTemplate<INT>::VeryInner; 39template struct N::Outer::Inner::InnerTemplate<INT>::UeberInner; // expected-error{{'UeberInner' does not name a tag member}} 40 41namespace N2 { 42 struct Outer2 { 43 template<typename T, typename U = T> 44 struct Inner { 45 void foo() { 46 enum { K1Val = sizeof(T) } k1; 47 enum K2 { K2Val = sizeof(T)*2 } k2a; 48 49 K2 k2b = K2Val; 50 51 struct S { T x, y; } s1; 52 struct { U x, y; } s2; 53 s1.x = s2.x; // expected-error{{incompatible}} 54 55 typedef T type; 56 type t2 = s1.x; 57 58 Inner i1; 59 i1.foo(); 60 Inner<T> i2; 61 i2.foo(); 62 } 63 }; 64 }; 65} 66 67template struct N2::Outer2::Inner<float>; 68template struct N2::Outer2::Inner<int*, float*>; // expected-note{{instantiation}} 69