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