1 // RUN: clang-cc -fsyntax-only -verify %s -std=c++0x 2 3 #ifndef __GXX_EXPERIMENTAL_CXX0X__ 4 #define __CONCAT(__X, __Y) __CONCAT1(__X, __Y) 5 #define __CONCAT1(__X, __Y) __X ## __Y 6 7 #define static_assert(__b, __m) \ 8 typedef int __CONCAT(__sa, __LINE__)[__b ? 1 : -1] 9 #endif 10 11 class C { 12 virtual void f() = 0; // expected-note {{pure virtual function 'f'}} 13 }; 14 15 static_assert(__is_abstract(C), "C has a pure virtual function"); 16 17 class D : C { 18 }; 19 20 static_assert(__is_abstract(D), "D inherits from an abstract class"); 21 22 class E : D { 23 virtual void f(); 24 }; 25 26 static_assert(!__is_abstract(E), "E inherits from an abstract class but implements f"); 27 28 C *d = new C; // expected-error {{allocation of an object of abstract type 'C'}} 29 30 C c; // expected-error {{variable type 'C' is an abstract class}} 31 void t1(C c); // expected-error {{parameter type 'C' is an abstract class}} 32 void t2(C); // expected-error {{parameter type 'C' is an abstract class}} 33 34 struct S { 35 C c; // expected-error {{field type 'C' is an abstract class}} 36 }; 37 38 void t3(const C&); 39 40 void f() { 41 C(); // expected-error {{allocation of an object of abstract type 'C'}} 42 t3(C()); // expected-error {{allocation of an object of abstract type 'C'}} 43 } 44 45 C e1[2]; // expected-error {{variable type 'C' is an abstract class}} 46 C (*e2)[2]; // expected-error {{variable type 'C' is an abstract class}} 47 C (**e3)[2]; // expected-error {{variable type 'C' is an abstract class}} 48 49 void t4(C c[2]); // expected-error {{parameter type 'C' is an abstract class}} 50 51 void t5(void (*)(C)); // expected-error {{parameter type 'C' is an abstract class}} 52 53 typedef void (*Func)(C); // expected-error {{parameter type 'C' is an abstract class}} 54 void t6(Func); 55 56 class F { 57 F a() { while (1) {} } // expected-error {{return type 'F' is an abstract class}} 58 59 class D { 60 void f(F c); // expected-error {{parameter type 'F' is an abstract class}} 61 }; 62 63 union U { 64 void u(F c); // expected-error {{parameter type 'F' is an abstract class}} 65 }; 66 67 virtual void f() = 0; // expected-note {{pure virtual function 'f'}} 68 }; 69 70 class Abstract; 71 72 void t7(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} 73 74 void t8() { 75 void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} 76 } 77 78 namespace N { 79 void h(Abstract a); // expected-error {{parameter type 'Abstract' is an abstract class}} 80 } 81 82 class Abstract { 83 virtual void f() = 0; // expected-note {{pure virtual function 'f'}} 84 }; 85 86 // <rdar://problem/6854087> 87 class foo { 88 public: 89 virtual foo *getFoo() = 0; 90 }; 91 92 class bar : public foo { 93 public: 94 virtual bar *getFoo(); 95 }; 96 97 bar x; 98 99 // <rdar://problem/6902298> 100 class A 101 { 102 public: 103 virtual void release() = 0; 104 virtual void release(int count) = 0; 105 virtual void retain() = 0; 106 }; 107 108 class B : public A 109 { 110 public: 111 virtual void release(); 112 virtual void release(int count); 113 virtual void retain(); 114 }; 115 116 void foo(void) 117 { 118 B b; 119 } 120 121 struct K { 122 int f; 123 virtual ~K(); 124 }; 125 126 struct L : public K { 127 void f(); 128 }; 129