blob: 7b4373538d2ab95aba6b4805e686b42d359d79ad [file] [log] [blame]
Douglas Gregore7450f52009-03-24 19:52:54 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3// Tests various places where requiring a complete type involves
4// instantiation of that type.
5
6template<typename T>
7struct X {
8 X(T);
9
10 T f; // expected-error{{data member instantiated with function type 'float (int)'}} \
11 // expected-error{{data member instantiated with function type 'int (int)'}} \
12 // expected-error{{data member instantiated with function type 'char (char)'}} \
13 // expected-error{{data member instantiated with function type 'short (short)'}} \
14 // expected-error{{data member instantiated with function type 'float (float)'}} \
15 // expected-error{{data member instantiated with function type 'long (long)'}}
16};
17
18X<int> f() { return 0; }
19
20struct XField {
21 X<float(int)> xf; // expected-note{{in instantiation of template class 'struct X<float (int)>' requested here}}
22};
23
24void test_subscript(X<double> *ptr1, X<int(int)> *ptr2, int i) {
25 (void)ptr1[i];
26 (void)ptr2[i]; // expected-note{{in instantiation of template class 'struct X<int (int)>' requested here}}
27}
28
29void test_arith(X<signed char> *ptr1, X<unsigned char> *ptr2,
30 X<char(char)> *ptr3, X<short(short)> *ptr4) {
31 (void)(ptr1 + 5);
32 // FIXME: if I drop the ')' after void, below, it still parses (!)
33 (void)(5 + ptr2);
34 (void)(ptr3 + 5); // expected-note{{in instantiation of template class 'struct X<char (char)>' requested here}}
35 (void)(5 + ptr4); // expected-note{{in instantiation of template class 'struct X<short (short)>' requested here}}
36}
37
38void test_new() {
39 (void)new X<float>(0);
40 (void)new X<float(float)>; // expected-note{{in instantiation of template class 'struct X<float (float)>' requested here}}
41}
42
43void test_memptr(X<long> *p1, long X<long>::*pm1,
44 X<long(long)> *p2, long (X<long(long)>::*pm2)(long)) {
45 (void)(p1->*pm1);
46 (void)(p2->*pm2); // expected-note{{in instantiation of template class 'struct X<long (long)>' requested here}}
47}