1 // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -std=c++11 -triple %itanium_abi_triple -fsyntax-only %s
2 // RUN: %clang_cc1 -fexceptions -fcxx-exceptions -std=c++11 -triple %ms_abi_triple -verify %s
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 when vtables are marked used.
11 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}}
15 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}}
23 virtual ~VC(); // expected-error {{member 'operator delete' found in multiple base classes of different types}}
27 // This marks VC's vtable used.
35 // In the MSVC ABI, functions must destroy their aggregate arguments. foo
36 // requires a dtor for B, but we can't implicitly define it because ~A is
37 // private. bar should be able to call A's private dtor without error, even
38 // though MSVC rejects bar.
45 struct B
: public A
{ // expected-note {{destructor of 'B' is implicitly deleted because base class 'Test2::A' has an inaccessible destructor}}
55 // D has a non-trivial implicit dtor that destroys C.
59 void foo(B b
) { } // expected-error {{attempt to use a deleted function}}
60 void bar(A a
) { } // no error; MSVC rejects this, but we skip the direct access check.
61 void baz(D d
) { } // no error
70 ~A(); // expected-note {{implicitly declared private here}}
76 void baz(A a
) { } // no error; MSVC rejects this, but the standard allows it.
78 // MSVC accepts foo() but we reject it for consistency with Itanium. MSVC also
79 // rejects this if A has a copy ctor or if we call A's ctor.
81 bar(*a
); // expected-error {{temporary of type 'Test3::A' has private destructor}}
87 // Don't try to access the dtor of an incomplete on a function declaration.
94 // Do the operator delete access control check from the context of the dtor.
97 void operator delete(void *);
103 // Previously, marking the vtable used here would do the operator delete
104 // lookup from this context, which doesn't have access.
113 void operator delete(void *);
118 virtual void m_fn1();
120 void fn1(B
*b
) { b
->m_fn1(); }
126 void operator delete(void *);
128 struct B
: public A
{