blob: d825cd7cc613c4ca7654faca714ea0eb8f5613cd [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor3cf538d2009-03-11 18:59:21 +00002
3template<typename T>
4struct 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
14void 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
22void test2(const X<float> *xf) {
John McCall7c2342d2010-03-10 11:27:22 +000023 (void)xf->x; // expected-note{{in instantiation of template class 'X<float>' requested here}}
Douglas Gregor3cf538d2009-03-11 18:59:21 +000024}
25
26void test3(const X<int(int)> *xf) {
John McCall7c2342d2010-03-10 11:27:22 +000027 (void)xf->x; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}}
Douglas Gregor3cf538d2009-03-11 18:59:21 +000028}
Douglas Gregor9679caf2010-05-12 17:27:19 +000029
30namespace 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}
Douglas Gregord27e50c2010-06-16 16:54:04 +000084
85namespace 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}