StmtPrinter: factor out arg printing code to PrintCallArgs
[clang.git] / test / SemaTemplate / instantiate-field.cpp
bloba148ee4e55ed925564c99ec8205ae68e1470036d
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 template<typename T>
4 struct X {
5 int x;
6 T y; // expected-error{{data member instantiated with function type}}
7 T* z;
8 T bitfield : 12; // expected-error{{bit-field 'bitfield' has non-integral type 'float'}} \
9 // expected-error{{data member instantiated with function type}}
11 mutable T x2; // expected-error{{data member instantiated with function type}}
14 void test1(const X<int> *xi) {
15 int i1 = xi->x;
16 const int &i2 = xi->y;
17 int* ip1 = xi->z;
18 int i3 = xi->bitfield;
19 xi->x2 = 17;
22 void test2(const X<float> *xf) {
23 (void)xf->x; // expected-note{{in instantiation of template class 'X<float>' requested here}}
26 void test3(const X<int(int)> *xf) {
27 (void)xf->x; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}}
30 namespace PR7123 {
31 template <class > struct requirement_;
33 template <void(*)()> struct instantiate
34 { };
36 template <class > struct requirement ;
37 struct failed ;
39 template <class Model> struct requirement<failed *Model::*>
41 static void failed()
43 ((Model*)0)->~Model(); // expected-note{{in instantiation of}}
47 template <class Model> struct requirement_<void(*)(Model)> : requirement<failed *Model::*>
48 { };
50 template <int> struct Requires_
51 { typedef void type; };
53 template <class Model> struct usage_requirements
55 ~usage_requirements()
56 {((Model*)0)->~Model(); } // expected-note{{in instantiation of}}
59 template < typename TT > struct BidirectionalIterator
61 enum
62 { value = 0 };
64 instantiate< requirement_<void(*)(usage_requirements<BidirectionalIterator>)>::failed> int534; // expected-note{{in instantiation of}}
66 ~BidirectionalIterator()
67 { i--; } // expected-error{{cannot decrement value of type 'PR7123::X'}}
69 TT i;
72 struct X
73 { };
75 template<typename RanIter>
76 typename Requires_< BidirectionalIterator<RanIter>::value >::type sort(RanIter,RanIter){}
78 void f()
80 X x;
81 sort(x,x);
85 namespace PR7355 {
86 template<typename T1> class A {
87 class D; // expected-note{{declared here}}
88 D d; //expected-error{{implicit instantiation of undefined member 'PR7355::A<int>::D'}}
91 A<int> ai; // expected-note{{in instantiation of}}
94 namespace PR8712 {
95 template <int dim>
96 class B {
97 public:
98 B(const unsigned char i);
99 unsigned char value : (dim > 0 ? dim : 1);
102 template <int dim>
103 inline B<dim>::B(const unsigned char i) : value(i) {}