• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
3 // PR7800
4 
5 // 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
11 class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
12 struct A {
13   virtual ~A();
14 };
15 
16 #ifdef MSABI
17 // expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
18 #endif
19 struct B : public virtual A {
20   NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
21 };
22 #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
26 struct D : public virtual B {
27   virtual void foo();
28   ~D();
29 };
30 #ifdef MSABI
31 D d; // expected-note {{implicit default constructor for 'D' first required here}}
32 #else
foo()33 void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
34 }
35 #endif
36 
37 #ifdef MSABI
38 // expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
39 #endif
40 struct E : public virtual A {
41   NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
42 };
43 #ifdef MSABI
44 // expected-note@+2 {{implicit default constructor for 'E' first required here}}
45 #endif
46 struct F : public E { // expected-note {{implicit destructor for 'E' first required here}}
47 };
48 #ifdef MSABI
49 // expected-note@+2 {{implicit default constructor for 'F' first required here}}
50 #endif
51 struct G : public virtual F {
52   virtual void foo();
53   ~G();
54 };
55 #ifdef MSABI
56 G g; // expected-note {{implicit default constructor for 'G' first required here}}
57 #else
foo()58 void G::foo() { // expected-note {{implicit destructor for 'F' first required here}}
59 }
60 #endif
61 
62 #ifdef MSABI
63 // expected-note@+3 {{'H' declared here}}
64 // expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
65 #endif
66 struct H : public virtual A {
67   NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
68 };
69 #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
73 struct I : public virtual H {
74   ~I();
75 };
76 #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
80 struct J : public I {
81   virtual void foo();
82   ~J();
83 };
84 #ifdef MSABI
85 J j; // expected-note {{implicit default constructor for 'J' first required here}}
86 #else
foo()87 void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
88 }
89 #endif
90