From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/SemaTemplate/instantiate-field.cpp | 104 ++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 clang/test/SemaTemplate/instantiate-field.cpp (limited to 'clang/test/SemaTemplate/instantiate-field.cpp') diff --git a/clang/test/SemaTemplate/instantiate-field.cpp b/clang/test/SemaTemplate/instantiate-field.cpp new file mode 100644 index 0000000..a148ee4 --- /dev/null +++ b/clang/test/SemaTemplate/instantiate-field.cpp @@ -0,0 +1,104 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +struct X { + int x; + T y; // expected-error{{data member instantiated with function type}} + T* z; + T bitfield : 12; // expected-error{{bit-field 'bitfield' has non-integral type 'float'}} \ + // expected-error{{data member instantiated with function type}} + + mutable T x2; // expected-error{{data member instantiated with function type}} +}; + +void test1(const X *xi) { + int i1 = xi->x; + const int &i2 = xi->y; + int* ip1 = xi->z; + int i3 = xi->bitfield; + xi->x2 = 17; +} + +void test2(const X *xf) { + (void)xf->x; // expected-note{{in instantiation of template class 'X' requested here}} +} + +void test3(const X *xf) { + (void)xf->x; // expected-note{{in instantiation of template class 'X' requested here}} +} + +namespace PR7123 { + template struct requirement_; + + template struct instantiate + { }; + + template struct requirement ; + struct failed ; + + template struct requirement + { + static void failed() + { + ((Model*)0)->~Model(); // expected-note{{in instantiation of}} + } + }; + + template struct requirement_ : requirement + { }; + + template struct Requires_ + { typedef void type; }; + + template struct usage_requirements + { + ~usage_requirements() + {((Model*)0)->~Model(); } // expected-note{{in instantiation of}} + }; + + template < typename TT > struct BidirectionalIterator + { + enum + { value = 0 }; + + instantiate< requirement_)>::failed> int534; // expected-note{{in instantiation of}} + + ~BidirectionalIterator() + { i--; } // expected-error{{cannot decrement value of type 'PR7123::X'}} + + TT i; + }; + + struct X + { }; + + template + typename Requires_< BidirectionalIterator::value >::type sort(RanIter,RanIter){} + + void f() + { + X x; + sort(x,x); + } +} + +namespace PR7355 { + template class A { + class D; // expected-note{{declared here}} + D d; //expected-error{{implicit instantiation of undefined member 'PR7355::A::D'}} + }; + + A ai; // expected-note{{in instantiation of}} +} + +namespace PR8712 { + template + class B { + public: + B(const unsigned char i); + unsigned char value : (dim > 0 ? dim : 1); + }; + + template + inline B::B(const unsigned char i) : value(i) {} +} -- cgit v1.2.3