// RUN: %clang_cc1 -fsyntax-only -verify %s // Tests various places where requiring a complete type involves // instantiation of that type. template struct X { X(T); T f; // expected-error{{data member instantiated with function type 'float (int)'}} \ // expected-error{{data member instantiated with function type 'int (int)'}} \ // expected-error{{data member instantiated with function type 'char (char)'}} \ // expected-error{{data member instantiated with function type 'short (short)'}} \ // expected-error{{data member instantiated with function type 'float (float)'}} }; X f() { return 0; } struct XField { X xf; // expected-note{{in instantiation of template class 'X' requested here}} }; void test_subscript(X *ptr1, X *ptr2, int i) { (void)ptr1[i]; (void)ptr2[i]; // expected-note{{in instantiation of template class 'X' requested here}} } void test_arith(X *ptr1, X *ptr2, X *ptr3, X *ptr4) { (void)(ptr1 + 5); (void)(5 + ptr2); (void)(ptr3 + 5); // expected-note{{in instantiation of template class 'X' requested here}} (void)(5 + ptr4); // expected-note{{in instantiation of template class 'X' requested here}} } void test_new() { (void)new X(0); (void)new X; // expected-note{{in instantiation of template class 'X' requested here}} } void test_memptr(X *p1, long X::*pm1, X *p2, long (X::*pm2)(long)) { (void)(p1->*pm1); } // Reference binding to a base template struct X1 { }; template struct X2 : public T { }; void refbind_base(X2 > &x2) { X1 &x1 = x2; } // Enumerate constructors for user-defined conversion. template struct X3 { X3(T); }; void enum_constructors(X1 &x1) { X3 > x3 = x1; } namespace PR6376 { template struct W { }; template struct X { template struct apply { typedef W type; }; }; template struct Y : public X::template apply::type { }; template struct Y; } namespace TemporaryObjectCopy { // Make sure we instantiate classes when we create a temporary copy. template struct X { X(T); }; template void f(T t) { const X &x = X(t); } template void f(int); } namespace PR7080 { template class X { typedef char true_t; class false_t { char dummy[2]; }; static true_t dispatch(U); static false_t dispatch(...); static T trigger(); public: enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; }; template class rv : public T { }; bool x = X&>::value; } namespace pr7199 { template class A; // expected-note {{template is declared here}} template class B { class A::C field; // expected-error {{implicit instantiation of undefined template 'pr7199::A'}} }; template class B; // expected-note {{in instantiation}} } namespace PR8425 { template class BaseT {}; template class DerivedT : public BaseT {}; template class FromT { public: operator DerivedT() const { return DerivedT(); } }; void test() { FromT ft; BaseT bt(ft); } }