1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc x(A x)3*f4a2713aSLionel Sambuctemplate <class A> int x(A x) { return x++; } y()4*f4a2713aSLionel Sambucint y() { return x<int>(1); } 5*f4a2713aSLionel Sambuc 6*f4a2713aSLionel Sambuc namespace PR5880 { 7*f4a2713aSLionel Sambuc template<typename T> 8*f4a2713aSLionel Sambuc struct A { 9*f4a2713aSLionel Sambuc static const int a = __builtin_offsetof(T, a.array[5].m); // expected-error{{no member named 'a' in 'HasM'}} 10*f4a2713aSLionel Sambuc }; 11*f4a2713aSLionel Sambuc struct HasM { 12*f4a2713aSLionel Sambuc float m; 13*f4a2713aSLionel Sambuc }; 14*f4a2713aSLionel Sambuc 15*f4a2713aSLionel Sambuc struct ArrayOfHasM { 16*f4a2713aSLionel Sambuc HasM array[10]; 17*f4a2713aSLionel Sambuc }; 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc struct B { ArrayOfHasM a; }; 20*f4a2713aSLionel Sambuc A<B> x; 21*f4a2713aSLionel Sambuc A<HasM> x2; // expected-note{{in instantiation of}} 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuc template<typename T> 24*f4a2713aSLionel Sambuc struct AnonymousUnion { 25*f4a2713aSLionel Sambuc union { 26*f4a2713aSLionel Sambuc int i; 27*f4a2713aSLionel Sambuc float f; 28*f4a2713aSLionel Sambuc }; 29*f4a2713aSLionel Sambuc }; 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc template<typename T> test_anon_union()32*f4a2713aSLionel Sambuc void test_anon_union() { 33*f4a2713aSLionel Sambuc int array1[__builtin_offsetof(AnonymousUnion<T>, f) == 0? 1 : -1]; 34*f4a2713aSLionel Sambuc int array2[__builtin_offsetof(AnonymousUnion<int>, f) == 0? 1 : -1]; 35*f4a2713aSLionel Sambuc } 36*f4a2713aSLionel Sambuc 37*f4a2713aSLionel Sambuc template void test_anon_union<int>(); 38*f4a2713aSLionel Sambuc } 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc namespace AddrOfClassMember { 41*f4a2713aSLionel Sambuc template <typename T> struct S { 42*f4a2713aSLionel Sambuc int n; fAddrOfClassMember::S43*f4a2713aSLionel Sambuc static void f() { 44*f4a2713aSLionel Sambuc +T::n; // expected-error {{invalid use of member}} 45*f4a2713aSLionel Sambuc } 46*f4a2713aSLionel Sambuc }; g()47*f4a2713aSLionel Sambuc void g() { S<S<int> >::f(); } // expected-note {{in instantiation of}} 48*f4a2713aSLionel Sambuc } 49