1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc template<typename T> 4*f4a2713aSLionel Sambuc struct X { 5*f4a2713aSLionel Sambuc int x; 6*f4a2713aSLionel Sambuc T y; // expected-error{{data member instantiated with function type}} 7*f4a2713aSLionel Sambuc T* z; 8*f4a2713aSLionel Sambuc T bitfield : 12; // expected-error{{bit-field 'bitfield' has non-integral type 'float'}} \ 9*f4a2713aSLionel Sambuc // expected-error{{data member instantiated with function type}} 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc mutable T x2; // expected-error{{data member instantiated with function type}} 12*f4a2713aSLionel Sambuc }; 13*f4a2713aSLionel Sambuc test1(const X<int> * xi)14*f4a2713aSLionel Sambucvoid test1(const X<int> *xi) { 15*f4a2713aSLionel Sambuc int i1 = xi->x; 16*f4a2713aSLionel Sambuc const int &i2 = xi->y; 17*f4a2713aSLionel Sambuc int* ip1 = xi->z; 18*f4a2713aSLionel Sambuc int i3 = xi->bitfield; 19*f4a2713aSLionel Sambuc xi->x2 = 17; 20*f4a2713aSLionel Sambuc } 21*f4a2713aSLionel Sambuc test2(const X<float> * xf)22*f4a2713aSLionel Sambucvoid test2(const X<float> *xf) { 23*f4a2713aSLionel Sambuc (void)xf->x; // expected-note{{in instantiation of template class 'X<float>' requested here}} 24*f4a2713aSLionel Sambuc } 25*f4a2713aSLionel Sambuc test3(const X<int (int)> * xf)26*f4a2713aSLionel Sambucvoid test3(const X<int(int)> *xf) { 27*f4a2713aSLionel Sambuc (void)xf->x; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}} 28*f4a2713aSLionel Sambuc } 29*f4a2713aSLionel Sambuc 30*f4a2713aSLionel Sambuc namespace PR7123 { 31*f4a2713aSLionel Sambuc template <class > struct requirement_; 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc template <void(*)()> struct instantiate 34*f4a2713aSLionel Sambuc { }; 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc template <class > struct requirement ; 37*f4a2713aSLionel Sambuc struct failed ; 38*f4a2713aSLionel Sambuc 39*f4a2713aSLionel Sambuc template <class Model> struct requirement<failed *Model::*> 40*f4a2713aSLionel Sambuc { failedPR7123::requirement41*f4a2713aSLionel Sambuc static void failed() 42*f4a2713aSLionel Sambuc { 43*f4a2713aSLionel Sambuc ((Model*)0)->~Model(); // expected-note{{in instantiation of}} 44*f4a2713aSLionel Sambuc } 45*f4a2713aSLionel Sambuc }; 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc template <class Model> struct requirement_<void(*)(Model)> : requirement<failed *Model::*> 48*f4a2713aSLionel Sambuc { }; 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc template <int> struct Requires_ 51*f4a2713aSLionel Sambuc { typedef void type; }; 52*f4a2713aSLionel Sambuc 53*f4a2713aSLionel Sambuc template <class Model> struct usage_requirements 54*f4a2713aSLionel Sambuc { ~usage_requirementsPR7123::usage_requirements55*f4a2713aSLionel Sambuc ~usage_requirements() 56*f4a2713aSLionel Sambuc {((Model*)0)->~Model(); } // expected-note{{in instantiation of}} 57*f4a2713aSLionel Sambuc }; 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc template < typename TT > struct BidirectionalIterator 60*f4a2713aSLionel Sambuc { 61*f4a2713aSLionel Sambuc enum 62*f4a2713aSLionel Sambuc { value = 0 }; 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc instantiate< requirement_<void(*)(usage_requirements<BidirectionalIterator>)>::failed> int534; // expected-note{{in instantiation of}} 65*f4a2713aSLionel Sambuc ~BidirectionalIteratorPR7123::BidirectionalIterator66*f4a2713aSLionel Sambuc ~BidirectionalIterator() 67*f4a2713aSLionel Sambuc { i--; } // expected-error{{cannot decrement value of type 'PR7123::X'}} 68*f4a2713aSLionel Sambuc 69*f4a2713aSLionel Sambuc TT i; 70*f4a2713aSLionel Sambuc }; 71*f4a2713aSLionel Sambuc 72*f4a2713aSLionel Sambuc struct X 73*f4a2713aSLionel Sambuc { }; 74*f4a2713aSLionel Sambuc 75*f4a2713aSLionel Sambuc template<typename RanIter> sort(RanIter,RanIter)76*f4a2713aSLionel Sambuc typename Requires_< BidirectionalIterator<RanIter>::value >::type sort(RanIter,RanIter){} 77*f4a2713aSLionel Sambuc f()78*f4a2713aSLionel Sambuc void f() 79*f4a2713aSLionel Sambuc { 80*f4a2713aSLionel Sambuc X x; 81*f4a2713aSLionel Sambuc sort(x,x); 82*f4a2713aSLionel Sambuc } 83*f4a2713aSLionel Sambuc } 84*f4a2713aSLionel Sambuc 85*f4a2713aSLionel Sambuc namespace PR7355 { 86*f4a2713aSLionel Sambuc template<typename T1> class A { 87*f4a2713aSLionel Sambuc class D; // expected-note{{declared here}} 88*f4a2713aSLionel Sambuc D d; //expected-error{{implicit instantiation of undefined member 'PR7355::A<int>::D'}} 89*f4a2713aSLionel Sambuc }; 90*f4a2713aSLionel Sambuc 91*f4a2713aSLionel Sambuc A<int> ai; // expected-note{{in instantiation of}} 92*f4a2713aSLionel Sambuc } 93*f4a2713aSLionel Sambuc 94*f4a2713aSLionel Sambuc namespace PR8712 { 95*f4a2713aSLionel Sambuc template <int dim> 96*f4a2713aSLionel Sambuc class B { 97*f4a2713aSLionel Sambuc public: 98*f4a2713aSLionel Sambuc B(const unsigned char i); 99*f4a2713aSLionel Sambuc unsigned char value : (dim > 0 ? dim : 1); 100*f4a2713aSLionel Sambuc }; 101*f4a2713aSLionel Sambuc 102*f4a2713aSLionel Sambuc template <int dim> B(const unsigned char i)103*f4a2713aSLionel Sambuc inline B<dim>::B(const unsigned char i) : value(i) {} 104*f4a2713aSLionel Sambuc } 105