2014-01-15 03:35:09 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
|
2010-08-08 07:11:44 +08:00
|
|
|
// PR7800
|
|
|
|
|
2014-01-14 03:48:13 +08:00
|
|
|
// The Microsoft ABI doesn't have the concept of key functions, so we have different
|
|
|
|
// expectations about when functions are first required for that case.
|
|
|
|
|
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+2 3 {{declared private here}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
|
2010-08-08 07:11:44 +08:00
|
|
|
struct A {
|
|
|
|
virtual ~A();
|
|
|
|
};
|
2010-08-08 13:07:06 +08:00
|
|
|
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
#endif
|
2010-08-08 07:11:44 +08:00
|
|
|
struct B : public virtual A {
|
|
|
|
NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+3 {{implicit default constructor for 'B' first required here}}
|
|
|
|
// expected-note@+2 {{implicit destructor for 'B' first required here}}
|
|
|
|
#endif
|
2010-08-08 07:11:44 +08:00
|
|
|
struct D : public virtual B {
|
|
|
|
virtual void foo();
|
|
|
|
~D();
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
D d; // expected-note {{implicit default constructor for 'D' first required here}}
|
|
|
|
#else
|
2013-06-13 11:34:55 +08:00
|
|
|
void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
|
2010-08-08 07:11:44 +08:00
|
|
|
}
|
2014-01-14 03:48:13 +08:00
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
struct E : public virtual A {
|
|
|
|
NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+2 {{implicit default constructor for 'E' first required here}}
|
|
|
|
#endif
|
2013-06-13 11:34:55 +08:00
|
|
|
struct F : public E { // expected-note {{implicit destructor for 'E' first required here}}
|
2010-08-08 13:07:06 +08:00
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+2 {{implicit default constructor for 'F' first required here}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
struct G : public virtual F {
|
|
|
|
virtual void foo();
|
|
|
|
~G();
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
G g; // expected-note {{implicit default constructor for 'G' first required here}}
|
|
|
|
#else
|
2013-06-13 11:34:55 +08:00
|
|
|
void G::foo() { // expected-note {{implicit destructor for 'F' first required here}}
|
2010-08-08 13:07:06 +08:00
|
|
|
}
|
2014-01-14 03:48:13 +08:00
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+3 {{'H' declared here}}
|
|
|
|
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
struct H : public virtual A {
|
|
|
|
NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-error@+3 {{implicit default constructor for 'I' must explicitly initialize the base class 'H' which does not have a default constructor}}
|
|
|
|
// expected-note@+2 {{implicit destructor for 'H' first required here}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
struct I : public virtual H {
|
|
|
|
~I();
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
// expected-note@+3 {{implicit default constructor for 'H' first required here}}
|
|
|
|
// expected-note@+2 {{implicit default constructor for 'I' first required here}}
|
|
|
|
#endif
|
2010-08-08 13:07:06 +08:00
|
|
|
struct J : public I {
|
|
|
|
virtual void foo();
|
|
|
|
~J();
|
|
|
|
};
|
2014-01-14 03:48:13 +08:00
|
|
|
#ifdef MSABI
|
|
|
|
J j; // expected-note {{implicit default constructor for 'J' first required here}}
|
|
|
|
#else
|
2013-06-13 11:34:55 +08:00
|
|
|
void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
|
2010-08-08 13:07:06 +08:00
|
|
|
}
|
2014-01-14 03:48:13 +08:00
|
|
|
#endif
|