1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 namespace PR5557 { 4 template <class T> struct A { 5 A(); 6 virtual void anchor(); 7 virtual int a(T x); 8 }; 9 template<class T> A<T>::A() {} 10 template<class T> void A<T>::anchor() { } 11 12 template<class T> int A<T>::a(T x) { 13 return *x; // expected-error{{requires pointer operand}} 14 } 15 16 void f(A<int> x) { 17 x.anchor(); // expected-note{{instantiation}} 18 } 19 20 template<typename T> 21 struct X { 22 virtual void f(); 23 }; 24 25 template<> 26 void X<int>::f() { } 27 } 28 29 template<typename T> 30 struct Base { 31 virtual ~Base() { 32 int *ptr = 0; 33 T t = ptr; // expected-error{{cannot initialize}} 34 } 35 }; 36 37 template<typename T> 38 struct Derived : Base<T> { 39 virtual void foo() { } 40 }; 41 42 template struct Derived<int>; // expected-note {{in instantiation of member function 'Base<int>::~Base' requested here}} 43 44 template<typename T> 45 struct HasOutOfLineKey { 46 HasOutOfLineKey() { } 47 virtual T *f(float *fp); 48 }; 49 50 template<typename T> 51 T *HasOutOfLineKey<T>::f(float *fp) { 52 return fp; // expected-error{{cannot initialize return object of type 'int *' with an lvalue of type 'float *'}} 53 } 54 55 HasOutOfLineKey<int> out_of_line; // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::f' requested here}} 56 57 namespace std { 58 class type_info; 59 } 60 61 namespace PR7114 { 62 class A { virtual ~A(); }; // expected-note{{declared private here}} 63 64 template<typename T> 65 class B { 66 public: 67 class Inner : public A { }; // expected-error{{base class 'PR7114::A' has private destructor}} 68 static Inner i; 69 static const unsigned value = sizeof(i) == 4; 70 }; 71 72 int f() { return B<int>::value; } 73 74 void test_typeid(B<float>::Inner bfi) { 75 (void)typeid(bfi); // expected-note{{implicit destructor}} 76 } 77 78 template<typename T> 79 struct X : A { 80 void f() { } 81 }; 82 83 void test_X(X<int> xi, X<float> xf) { 84 xi.f(); 85 } 86 } 87 88 namespace DynamicCast { 89 struct Y {}; 90 template<typename T> struct X : virtual Y { 91 virtual void foo() { T x; } // expected-error {{variable has incomplete type 'void'}} 92 }; 93 template<typename T> struct X2 : virtual Y { 94 virtual void foo() { T x; } 95 }; 96 Y* f(X<void>* x) { return dynamic_cast<Y*>(x); } // expected-note {{in instantiation of member function 'DynamicCast::X<void>::foo' requested here}} 97 Y* f2(X<void>* x) { return dynamic_cast<Y*>(x); } 98 } 99