blob: c46cf5a8c9ef722d3c9c91007199ecd0c926922a [file] [log] [blame]
Hans Wennborgc9bd88e2014-01-14 19:35:09 +00001// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
2// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
Eli Friedmanaab1fda2010-08-07 23:11:44 +00003// PR7800
4
Hans Wennborg9125b082014-01-13 19:48:13 +00005// The Microsoft ABI doesn't have the concept of key functions, so we have different
6// expectations about when functions are first required for that case.
7
8#ifdef MSABI
9// expected-note@+2 3 {{declared private here}}
10#endif
Eli Friedman9129b002010-08-08 05:07:06 +000011class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
Eli Friedmanaab1fda2010-08-07 23:11:44 +000012struct A {
13 virtual ~A();
14};
Eli Friedman9129b002010-08-08 05:07:06 +000015
Hans Wennborg9125b082014-01-13 19:48:13 +000016#ifdef MSABI
17// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
18#endif
Eli Friedmanaab1fda2010-08-07 23:11:44 +000019struct B : public virtual A {
20 NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
21};
Hans Wennborg9125b082014-01-13 19:48:13 +000022#ifdef MSABI
23// expected-note@+3 {{implicit default constructor for 'B' first required here}}
24// expected-note@+2 {{implicit destructor for 'B' first required here}}
25#endif
Eli Friedmanaab1fda2010-08-07 23:11:44 +000026struct D : public virtual B {
27 virtual void foo();
28 ~D();
29};
Hans Wennborg9125b082014-01-13 19:48:13 +000030#ifdef MSABI
31D d; // expected-note {{implicit default constructor for 'D' first required here}}
32#else
Richard Smithf24e6e72013-06-13 03:34:55 +000033void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
Eli Friedmanaab1fda2010-08-07 23:11:44 +000034}
Hans Wennborg9125b082014-01-13 19:48:13 +000035#endif
Eli Friedman9129b002010-08-08 05:07:06 +000036
Hans Wennborg9125b082014-01-13 19:48:13 +000037#ifdef MSABI
38// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
39#endif
Eli Friedman9129b002010-08-08 05:07:06 +000040struct E : public virtual A {
41 NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
42};
Hans Wennborg9125b082014-01-13 19:48:13 +000043#ifdef MSABI
44// expected-note@+2 {{implicit default constructor for 'E' first required here}}
45#endif
Richard Smithf24e6e72013-06-13 03:34:55 +000046struct F : public E { // expected-note {{implicit destructor for 'E' first required here}}
Eli Friedman9129b002010-08-08 05:07:06 +000047};
Hans Wennborg9125b082014-01-13 19:48:13 +000048#ifdef MSABI
49// expected-note@+2 {{implicit default constructor for 'F' first required here}}
50#endif
Eli Friedman9129b002010-08-08 05:07:06 +000051struct G : public virtual F {
52 virtual void foo();
53 ~G();
54};
Hans Wennborg9125b082014-01-13 19:48:13 +000055#ifdef MSABI
56G g; // expected-note {{implicit default constructor for 'G' first required here}}
57#else
Richard Smithf24e6e72013-06-13 03:34:55 +000058void G::foo() { // expected-note {{implicit destructor for 'F' first required here}}
Eli Friedman9129b002010-08-08 05:07:06 +000059}
Hans Wennborg9125b082014-01-13 19:48:13 +000060#endif
Eli Friedman9129b002010-08-08 05:07:06 +000061
Hans Wennborg9125b082014-01-13 19:48:13 +000062#ifdef MSABI
63// expected-note@+3 {{'H' declared here}}
64// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
65#endif
Eli Friedman9129b002010-08-08 05:07:06 +000066struct H : public virtual A {
67 NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
68};
Hans Wennborg9125b082014-01-13 19:48:13 +000069#ifdef MSABI
70// expected-error@+3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
71// expected-note@+2 {{implicit destructor for 'H' first required here}}
72#endif
Eli Friedman9129b002010-08-08 05:07:06 +000073struct I : public virtual H {
74 ~I();
75};
Hans Wennborg9125b082014-01-13 19:48:13 +000076#ifdef MSABI
77// expected-note@+3 {{implicit default constructor for 'H' first required here}}
78// expected-note@+2 {{implicit default constructor for 'I' first required here}}
79#endif
Eli Friedman9129b002010-08-08 05:07:06 +000080struct J : public I {
81 virtual void foo();
82 ~J();
83};
Hans Wennborg9125b082014-01-13 19:48:13 +000084#ifdef MSABI
85J j; // expected-note {{implicit default constructor for 'J' first required here}}
86#else
Richard Smithf24e6e72013-06-13 03:34:55 +000087void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
Eli Friedman9129b002010-08-08 05:07:06 +000088}
Hans Wennborg9125b082014-01-13 19:48:13 +000089#endif