1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | |
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}} |
10 | |
11 | mutable T x2; // expected-error{{data member instantiated with function type}} |
12 | }; |
13 | |
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; |
20 | } |
21 | |
22 | void test2(const X<float> *xf) { |
23 | (void)xf->x; // expected-note{{in instantiation of template class 'X<float>' requested here}} |
24 | } |
25 | |
26 | void test3(const X<int(int)> *xf) { |
27 | (void)xf->x; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}} |
28 | } |
29 | |
30 | namespace PR7123 { |
31 | template <class > struct requirement_; |
32 | |
33 | template <void(*)()> struct instantiate |
34 | { }; |
35 | |
36 | template <class > struct requirement ; |
37 | struct failed ; |
38 | |
39 | template <class Model> struct requirement<failed *Model::*> |
40 | { |
41 | static void failed() |
42 | { |
43 | ((Model*)0)->~Model(); // expected-note{{in instantiation of}} |
44 | } |
45 | }; |
46 | |
47 | template <class Model> struct requirement_<void(*)(Model)> : requirement<failed *Model::*> |
48 | { }; |
49 | |
50 | template <int> struct Requires_ |
51 | { typedef void type; }; |
52 | |
53 | template <class Model> struct usage_requirements |
54 | { |
55 | ~usage_requirements() |
56 | {((Model*)0)->~Model(); } // expected-note{{in instantiation of}} |
57 | }; |
58 | |
59 | template < typename TT > struct BidirectionalIterator |
60 | { |
61 | enum |
62 | { value = 0 }; |
63 | |
64 | instantiate< requirement_<void(*)(usage_requirements<BidirectionalIterator>)>::failed> int534; // expected-note{{in instantiation of}} |
65 | |
66 | ~BidirectionalIterator() |
67 | { i--; } // expected-error{{cannot decrement value of type 'PR7123::X'}} |
68 | |
69 | TT i; |
70 | }; |
71 | |
72 | struct X |
73 | { }; |
74 | |
75 | template<typename RanIter> |
76 | typename Requires_< BidirectionalIterator<RanIter>::value >::type sort(RanIter,RanIter){} |
77 | |
78 | void f() |
79 | { |
80 | X x; |
81 | sort(x,x); |
82 | } |
83 | } |
84 | |
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'}} |
89 | }; |
90 | |
91 | A<int> ai; // expected-note{{in instantiation of}} |
92 | } |
93 | |
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); |
100 | }; |
101 | |
102 | template <int dim> |
103 | inline B<dim>::B(const unsigned char i) : value(i) {} |
104 | } |
105 | |