Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
Anders Carlsson | 7ca4643 | 2009-12-05 17:04:47 +0000 | [diff] [blame] | 2 | |
| 3 | namespace { |
Anders Carlsson | 7ca4643 | 2009-12-05 17:04:47 +0000 | [diff] [blame] | 4 | struct A { |
| 5 | virtual void f() { } |
| 6 | }; |
Anders Carlsson | 7ca4643 | 2009-12-05 17:04:47 +0000 | [diff] [blame] | 7 | } |
| 8 | |
Anders Carlsson | 152d4dc | 2009-12-05 22:19:10 +0000 | [diff] [blame] | 9 | void f() { A b; } |
| 10 | |
| 11 | struct B { |
| 12 | B(); |
| 13 | virtual void f(); |
| 14 | }; |
| 15 | |
| 16 | B::B() { } |
| 17 | |
Anders Carlsson | 891c8b7 | 2009-12-05 22:24:38 +0000 | [diff] [blame] | 18 | struct C { |
| 19 | C(); |
| 20 | virtual void f() { } |
| 21 | }; |
| 22 | |
| 23 | C::C() { } |
| 24 | |
Anders Carlsson | 5794c97 | 2009-12-06 00:53:22 +0000 | [diff] [blame] | 25 | struct D { |
| 26 | virtual void f(); |
| 27 | }; |
| 28 | |
| 29 | void D::f() { } |
| 30 | |
Eli Friedman | 470fb73 | 2009-12-11 20:48:18 +0000 | [diff] [blame] | 31 | static struct : D { } e; |
| 32 | |
Anders Carlsson | 152d4dc | 2009-12-05 22:19:10 +0000 | [diff] [blame] | 33 | // B has a key function that is not defined in this translation unit so its vtable |
| 34 | // has external linkage. |
| 35 | // CHECK: @_ZTV1B = external constant |
| 36 | |
Anders Carlsson | 891c8b7 | 2009-12-05 22:24:38 +0000 | [diff] [blame] | 37 | // C has no key function, so its vtable should have weak_odr linkage. |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 38 | // CHECK: @_ZTS1C = weak_odr constant |
| 39 | // CHECK: @_ZTI1C = weak_odr constant |
Anders Carlsson | 891c8b7 | 2009-12-05 22:24:38 +0000 | [diff] [blame] | 40 | // CHECK: @_ZTV1C = weak_odr constant |
| 41 | |
Anders Carlsson | 5794c97 | 2009-12-06 00:53:22 +0000 | [diff] [blame] | 42 | // D has a key function that is defined in this translation unit so its vtable is |
| 43 | // defined in the translation unit. |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 44 | // CHECK: @_ZTS1D = constant |
| 45 | // CHECK: @_ZTI1D = constant |
Anders Carlsson | 5794c97 | 2009-12-06 00:53:22 +0000 | [diff] [blame] | 46 | // CHECK: @_ZTV1D = constant |
| 47 | |
Eli Friedman | 470fb73 | 2009-12-11 20:48:18 +0000 | [diff] [blame] | 48 | // The anonymous struct for e has no linkage, so the vtable should have |
| 49 | // internal linkage. |
| 50 | // CHECK: @"_ZTS3$_0" = internal constant |
| 51 | // CHECK: @"_ZTI3$_0" = internal constant |
| 52 | // CHECK: @"_ZTV3$_0" = internal constant |
| 53 | |
Anders Carlsson | 152d4dc | 2009-12-05 22:19:10 +0000 | [diff] [blame] | 54 | // The A vtable should have internal linkage since it is inside an anonymous |
| 55 | // namespace. |
Anders Carlsson | 31b7f52 | 2009-12-11 02:46:30 +0000 | [diff] [blame] | 56 | // CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant |
| 57 | // CHECK: @_ZTIN12_GLOBAL__N_11AE = internal constant |
Anders Carlsson | 152d4dc | 2009-12-05 22:19:10 +0000 | [diff] [blame] | 58 | // CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant |