1 // RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi itanium -fsyntax-only %s 2 // RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi microsoft -verify -DMSVC_ABI %s 3 4 namespace Test1 { 5 6 // Should be accepted under the Itanium ABI (first RUN line) but rejected 7 // under the Microsoft ABI (second RUN line), as Microsoft ABI requires 8 // operator delete() lookups to be done at all virtual destructor declaration 9 // points. 10 11 struct A { 12 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}} 13 }; 14 15 struct B { 16 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}} 17 }; 18 19 struct C : A, B { 20 ~C(); 21 }; 22 23 struct VC : A, B { 24 virtual ~VC(); // expected-error {{member 'operator delete' found in multiple base classes of different types}} 25 }; 26 27 } 28 29 namespace Test2 { 30 31 // In the MSVC ABI, functions must destroy their aggregate arguments. foo 32 // requires a dtor for B, but we can't implicitly define it because ~A is 33 // private. bar should be able to call A's private dtor without error, even 34 // though MSVC rejects bar. 35 36 class A { 37 private: 38 ~A(); // expected-note 2{{declared private here}} 39 int a; 40 }; 41 42 struct B : public A { // expected-error {{base class 'Test2::A' has private destructor}} 43 int b; 44 }; 45 46 struct C { 47 ~C(); 48 int c; 49 }; 50 51 struct D { 52 // D has a non-trivial implicit dtor that destroys C. 53 C o; 54 }; 55 56 void foo(B b) { } // expected-note {{implicit destructor for 'Test2::B' first required here}} 57 void bar(A a) { } // expected-error {{variable of type 'Test2::A' has private destructor}} 58 void baz(D d) { } // no error 59 60 } 61 62 #ifdef MSVC_ABI 63 namespace Test3 { 64 65 class A { 66 A(); 67 ~A(); // expected-note 2{{implicitly declared private here}} 68 friend void bar(A); 69 int a; 70 }; 71 72 void bar(A a) { } 73 void baz(A a) { } // expected-error {{variable of type 'Test3::A' has private destructor}} 74 75 // MSVC accepts foo() but we reject it for consistency with Itanium. MSVC also 76 // rejects this if A has a copy ctor or if we call A's ctor. 77 void foo(A *a) { 78 bar(*a); // expected-error {{temporary of type 'Test3::A' has private destructor}} 79 } 80 } 81 #endif 82 83 namespace Test4 { 84 // Don't try to access the dtor of an incomplete on a function declaration. 85 class A; 86 void foo(A a); 87 } 88