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