Sebastian Redl | 58a2cd8 | 2011-04-24 16:28:06 +0000 | [diff] [blame] | 1 | // no PCH |
Sebastian Redl | eebafe5 | 2011-04-29 08:19:03 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -emit-llvm-only -include %s -include %s %s |
Sebastian Redl | 58a2cd8 | 2011-04-24 16:28:06 +0000 | [diff] [blame] | 3 | // with PCH |
Sebastian Redl | eebafe5 | 2011-04-29 08:19:03 +0000 | [diff] [blame] | 4 | // RUN: %clang_cc1 -emit-llvm-only -chain-include %s -chain-include %s %s |
Sebastian Redl | 58a2cd8 | 2011-04-24 16:28:06 +0000 | [diff] [blame] | 5 | #if !defined(PASS1) |
| 6 | #define PASS1 |
| 7 | |
| 8 | // A base with a virtual dtor. |
| 9 | struct A { |
| 10 | virtual ~A(); |
| 11 | }; |
| 12 | |
| 13 | // A derived class with an implicit virtual dtor. |
| 14 | struct B : A { |
| 15 | // Key function to suppress vtable definition. |
| 16 | virtual void virt(); |
| 17 | }; |
| 18 | |
| 19 | #elif !defined(PASS2) |
| 20 | #define PASS2 |
| 21 | |
| 22 | // Further derived class that requires ~B(). |
| 23 | // Causes definition of ~B(), but it was lost when saving PCH. |
| 24 | struct C : B { |
| 25 | C(); |
| 26 | ~C() {} |
| 27 | }; |
| 28 | |
| 29 | #else |
| 30 | |
| 31 | void foo() { |
| 32 | // Variable that requires ~C(). |
| 33 | C c; |
| 34 | } |
| 35 | |
| 36 | // VTable placement would again cause definition of ~B(), hiding the bug, |
| 37 | // if not for B::virt(), which suppresses the placement. |
| 38 | |
| 39 | #endif |