blob: d264bab09bf74249022915e137ef822f5fd71f0a [file] [log] [blame]
Peter Collingbourneb289fe62013-05-20 14:12:25 +00001// RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi itanium -fsyntax-only %s
Reid Kleckner23f4c4b2013-06-21 12:45:15 +00002// RUN: %clang_cc1 -triple i686-pc-win32 -cxx-abi microsoft -verify -DMSVC_ABI %s
3
4namespace Test1 {
Peter Collingbourneb289fe62013-05-20 14:12:25 +00005
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
11struct A {
12 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}}
13};
14
15struct B {
16 void operator delete(void *); // expected-note {{member found by ambiguous name lookup}}
17};
18
19struct C : A, B {
20 ~C();
21};
22
23struct VC : A, B {
24 virtual ~VC(); // expected-error {{member 'operator delete' found in multiple base classes of different types}}
25};
Reid Kleckner23f4c4b2013-06-21 12:45:15 +000026
27}
28
29namespace 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
36class A {
37private:
38 ~A(); // expected-note 2{{declared private here}}
39 int a;
40};
41
42struct B : public A { // expected-error {{base class 'Test2::A' has private destructor}}
43 int b;
44};
45
46struct C {
47 ~C();
48 int c;
49};
50
51struct D {
52 // D has a non-trivial implicit dtor that destroys C.
53 C o;
54};
55
56void foo(B b) { } // expected-note {{implicit destructor for 'Test2::B' first required here}}
57void bar(A a) { } // expected-error {{variable of type 'Test2::A' has private destructor}}
58void baz(D d) { } // no error
59
60}
61
62#ifdef MSVC_ABI
63namespace Test3 {
64
65class A {
66 A();
67 ~A(); // expected-note 2{{implicitly declared private here}}
68 friend void bar(A);
69 int a;
70};
71
72void bar(A a) { }
73void 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.
77void foo(A *a) {
78 bar(*a); // expected-error {{temporary of type 'Test3::A' has private destructor}}
79}
80}
81#endif
82
83namespace Test4 {
84// Don't try to access the dtor of an incomplete on a function declaration.
85class A;
86void foo(A a);
87}