1 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -triple %ms_abi_triple -DMSABI -fsyntax-only -verify %s
4 // Tests various places where requiring a complete type involves
5 // instantiation of that type.
12 // expected-error@+2{{data member instantiated with function type 'long (long)'}}
14 T f
; // expected-error{{data member instantiated with function type 'float (int)'}} \
15 // expected-error{{data member instantiated with function type 'int (int)'}} \
16 // expected-error{{data member instantiated with function type 'char (char)'}} \
17 // expected-error{{data member instantiated with function type 'short (short)'}} \
18 // expected-error{{data member instantiated with function type 'float (float)'}}
21 X
<int> f() { return 0; }
24 X
<float(int)> xf
; // expected-note{{in instantiation of template class 'X<float (int)>' requested here}}
27 void test_subscript(X
<double> *ptr1
, X
<int(int)> *ptr2
, int i
) {
29 (void)ptr2
[i
]; // expected-note{{in instantiation of template class 'X<int (int)>' requested here}}
32 void test_arith(X
<signed char> *ptr1
, X
<unsigned char> *ptr2
,
33 X
<char(char)> *ptr3
, X
<short(short)> *ptr4
) {
36 (void)(ptr3
+ 5); // expected-note{{in instantiation of template class 'X<char (char)>' requested here}}
37 (void)(5 + ptr4
); // expected-note{{in instantiation of template class 'X<short (short)>' requested here}}
41 (void)new X
<float>(0);
42 (void)new X
<float(float)>; // expected-note{{in instantiation of template class 'X<float (float)>' requested here}}
45 void test_memptr(X
<long> *p1
, long X
<long>::*pm1
,
48 long (X
<long(long)>::*pm2
)(long)) { // expected-note{{in instantiation of template class 'X<long (long)>' requested here}}
50 long (X
<long(long)>::*pm2
)(long)) {
55 // Reference binding to a base
60 struct X2
: public T
{ };
62 void refbind_base(X2
<X1
<int> > &x2
) {
66 // Enumerate constructors for user-defined conversion.
72 void enum_constructors(X1
<float> &x1
) {
73 X3
<X1
<float> > x3
= x1
;
77 template<typename T
, typename U
> struct W
{ };
87 template<typename T
, typename U
>
88 struct Y
: public X
<T
>::template apply
<U
>::type
{ };
90 template struct Y
<int, float>;
93 namespace TemporaryObjectCopy
{
94 // Make sure we instantiate classes when we create a temporary copy.
102 const X
<int> &x
= X
<int>(t
);
105 template void f(int);
109 template <class T
, class U
>
113 class false_t
{ char dummy
[2]; };
114 static true_t
dispatch(U
);
115 static false_t
dispatch(...);
118 enum { value
= sizeof(dispatch(trigger())) == sizeof(true_t
) };
125 bool x
= X
<int, rv
<int>&>::value
;
129 template <class T
> class A
; // expected-note {{template is declared here}}
130 template <class T
> class B
{
131 class A
<T
>::C field
; // expected-error {{implicit instantiation of undefined template 'pr7199::A<int>'}}
134 template class B
<int>; // expected-note {{in instantiation}}
138 template <typename T
>
141 template <typename T
>
142 class DerivedT
: public BaseT
<T
> {};
144 template <typename T
>
147 operator DerivedT
<T
>() const { return DerivedT
<T
>(); }