xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/chain-implicit-definition.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // no PCH
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm-only -include %s -include %s %s
3*f4a2713aSLionel Sambuc // with PCH
4*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm-only -chain-include %s -chain-include %s %s
5*f4a2713aSLionel Sambuc #if !defined(PASS1)
6*f4a2713aSLionel Sambuc #define PASS1
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc // A base with a virtual dtor.
9*f4a2713aSLionel Sambuc struct A {
10*f4a2713aSLionel Sambuc   virtual ~A();
11*f4a2713aSLionel Sambuc };
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc // A derived class with an implicit virtual dtor.
14*f4a2713aSLionel Sambuc struct B : A {
15*f4a2713aSLionel Sambuc   // Key function to suppress vtable definition.
16*f4a2713aSLionel Sambuc   virtual void virt();
17*f4a2713aSLionel Sambuc };
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc #elif !defined(PASS2)
20*f4a2713aSLionel Sambuc #define PASS2
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // Further derived class that requires ~B().
23*f4a2713aSLionel Sambuc // Causes definition of ~B(), but it was lost when saving PCH.
24*f4a2713aSLionel Sambuc struct C : B {
25*f4a2713aSLionel Sambuc   C();
~CC26*f4a2713aSLionel Sambuc   ~C() {}
27*f4a2713aSLionel Sambuc };
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc #else
30*f4a2713aSLionel Sambuc 
foo()31*f4a2713aSLionel Sambuc void foo() {
32*f4a2713aSLionel Sambuc   // Variable that requires ~C().
33*f4a2713aSLionel Sambuc   C c;
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc // VTable placement would again cause definition of ~B(), hiding the bug,
37*f4a2713aSLionel Sambuc // if not for B::virt(), which suppresses the placement.
38*f4a2713aSLionel Sambuc 
39*f4a2713aSLionel Sambuc #endif
40