blob: 6d3cf240096baf13ec085a79b56b3381823d92f2 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
Anders Carlsson7ca46432009-12-05 17:04:47 +00002
3namespace {
Anders Carlsson7ca46432009-12-05 17:04:47 +00004 struct A {
5 virtual void f() { }
6 };
Anders Carlsson7ca46432009-12-05 17:04:47 +00007}
8
Anders Carlsson152d4dc2009-12-05 22:19:10 +00009void f() { A b; }
10
11struct B {
12 B();
13 virtual void f();
14};
15
16B::B() { }
17
Anders Carlsson891c8b72009-12-05 22:24:38 +000018struct C {
19 C();
20 virtual void f() { }
21};
22
23C::C() { }
24
Anders Carlsson5794c972009-12-06 00:53:22 +000025struct D {
26 virtual void f();
27};
28
29void D::f() { }
30
Eli Friedman470fb732009-12-11 20:48:18 +000031static struct : D { } e;
32
Anders Carlsson152d4dc2009-12-05 22:19:10 +000033// 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 Carlsson891c8b72009-12-05 22:24:38 +000037// C has no key function, so its vtable should have weak_odr linkage.
Anders Carlsson31b7f522009-12-11 02:46:30 +000038// CHECK: @_ZTS1C = weak_odr constant
39// CHECK: @_ZTI1C = weak_odr constant
Anders Carlsson891c8b72009-12-05 22:24:38 +000040// CHECK: @_ZTV1C = weak_odr constant
41
Anders Carlsson5794c972009-12-06 00:53:22 +000042// D has a key function that is defined in this translation unit so its vtable is
43// defined in the translation unit.
Anders Carlsson31b7f522009-12-11 02:46:30 +000044// CHECK: @_ZTS1D = constant
45// CHECK: @_ZTI1D = constant
Anders Carlsson5794c972009-12-06 00:53:22 +000046// CHECK: @_ZTV1D = constant
47
Eli Friedman470fb732009-12-11 20:48:18 +000048// 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 Carlsson152d4dc2009-12-05 22:19:10 +000054// The A vtable should have internal linkage since it is inside an anonymous
55// namespace.
Anders Carlsson31b7f522009-12-11 02:46:30 +000056// CHECK: @_ZTSN12_GLOBAL__N_11AE = internal constant
57// CHECK: @_ZTIN12_GLOBAL__N_11AE = internal constant
Anders Carlsson152d4dc2009-12-05 22:19:10 +000058// CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant