File: virtual-base-used.cpp

package info (click to toggle)
llvm-toolchain-3.7 1%3A3.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 345,556 kB
  • ctags: 362,199
  • sloc: cpp: 2,156,381; ansic: 458,339; objc: 91,547; python: 89,988; asm: 86,305; sh: 21,479; makefile: 6,853; perl: 5,601; ml: 5,458; pascal: 3,933; lisp: 2,429; xml: 686; cs: 239; php: 202; csh: 117
file content (89 lines) | stat: -rw-r--r-- 2,880 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// RUN: %clang_cc1 -fsyntax-only -triple %itanium_abi_triple -verify %s
// RUN: %clang_cc1 -fsyntax-only -triple %ms_abi_triple -DMSABI -verify %s
// PR7800

// 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
class NoDestroy { ~NoDestroy(); }; // expected-note 3 {{declared private here}}
struct A {
  virtual ~A();
};

#ifdef MSABI
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
#endif
struct B : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
#ifdef MSABI
// expected-note@+3 {{implicit default constructor for 'B' first required here}}
// expected-note@+2 {{implicit destructor for 'B' first required here}}
#endif
struct D : public virtual B {
  virtual void foo();
  ~D();
};
#ifdef MSABI
D d; // expected-note {{implicit default constructor for 'D' first required here}}
#else
void D::foo() { // expected-note {{implicit destructor for 'B' first required here}}
}
#endif

#ifdef MSABI
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
#endif
struct E : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
#ifdef MSABI
// expected-note@+2 {{implicit default constructor for 'E' first required here}}
#endif
struct F : public E { // expected-note {{implicit destructor for 'E' first required here}}
};
#ifdef MSABI
// expected-note@+2 {{implicit default constructor for 'F' first required here}}
#endif
struct G : public virtual F {
  virtual void foo();
  ~G();
};
#ifdef MSABI
G g; // expected-note {{implicit default constructor for 'G' first required here}}
#else
void G::foo() { // expected-note {{implicit destructor for 'F' first required here}}
}
#endif

#ifdef MSABI
// expected-note@+3 {{'H' declared here}}
// expected-error@+3 {{field of type 'NoDestroy' has private destructor}}
#endif
struct H : public virtual A {
  NoDestroy x; // expected-error {{field of type 'NoDestroy' has private destructor}}
};
#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
struct I : public virtual H {
  ~I();
};
#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
struct J : public I {
  virtual void foo();
  ~J();
};
#ifdef MSABI
J j; // expected-note {{implicit default constructor for 'J' first required here}}
#else
void J::foo() { // expected-note {{implicit destructor for 'H' first required here}}
}
#endif