blob: 11f328a1e48eb619bee2b1122262ed8269cb69a9 [file] [log] [blame]
Anders Carlsson8d145152009-12-20 22:30:54 +00001// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2#include <typeinfo>
Anders Carlsson4e713562009-12-11 16:37:06 +00003
4// CHECK: _ZTS1B = constant
5// CHECK: _ZTS1A = weak_odr constant
6// CHECK: _ZTI1A = weak_odr constant
7// CHECK: _ZTI1B = constant
Anders Carlsson8d145152009-12-20 22:30:54 +00008// CHECK: _ZTSP1C = internal constant
Anders Carlsson625c1ae2009-12-21 00:41:42 +00009// CHECK: _ZTS1C = internal constant
10// CHECK: _ZTI1C = internal constant
Anders Carlsson8d145152009-12-20 22:30:54 +000011// CHECK: _ZTIP1C = internal constant
12// CHECK: _ZTSPP1C = internal constant
13// CHECK: _ZTIPP1C = internal constant
Anders Carlsson17fa6f92009-12-20 23:37:55 +000014// CHECK: _ZTSM1Ci = internal constant
15// CHECK: _ZTIM1Ci = internal constant
16// CHECK: _ZTSPM1Ci = internal constant
17// CHECK: _ZTIPM1Ci = internal constant
18// CHECK: _ZTSM1CS_ = internal constant
19// CHECK: _ZTIM1CS_ = internal constant
20// CHECK: _ZTSM1CPS_ = internal constant
21// CHECK: _ZTIM1CPS_ = internal constant
22// CHECK: _ZTSM1A1C = internal constant
23// CHECK: _ZTIM1A1C = internal constant
24// CHECK: _ZTSM1AP1C = internal constant
25// CHECK: _ZTIM1AP1C = internal constant
26
Anders Carlsson610b0d92009-12-21 00:57:38 +000027// CHECK: _ZTSN12_GLOBAL__N_11DE = internal constant
28// CHECK: _ZTIN12_GLOBAL__N_11DE = internal constant
29// CHECK: _ZTSPN12_GLOBAL__N_11DE = internal constant
30// CHECK: _ZTIPN12_GLOBAL__N_11DE = internal constant
31
Anders Carlsson4e713562009-12-11 16:37:06 +000032// A has no key function, so its RTTI data should be weak_odr.
33struct A { };
34
35// B has a key function defined in the translation unit, so the RTTI data should
36// be emitted in this translation unit and have external linkage.
37struct B : A {
38 virtual void f();
39};
40void B::f() { }
Anders Carlsson8d145152009-12-20 22:30:54 +000041
42// C is an incomplete class type, so any direct or indirect pointer types should have
43// internal linkage, as should the type info for C itself (FIXME).
44struct C;
45
Anders Carlsson610b0d92009-12-21 00:57:38 +000046void t1() {
Anders Carlsson8d145152009-12-20 22:30:54 +000047 (void)typeid(C*);
48 (void)typeid(C**);
Anders Carlsson17fa6f92009-12-20 23:37:55 +000049 (void)typeid(int C::*);
50 (void)typeid(int C::**);
51 (void)typeid(C C::*);
52 (void)typeid(C *C::*);
53 (void)typeid(C A::*);
54 (void)typeid(C* A::*);
Anders Carlsson8d145152009-12-20 22:30:54 +000055}
56
Anders Carlsson610b0d92009-12-21 00:57:38 +000057namespace {
58 // D is inside an anonymous namespace, so all type information related to D should have
59 // internal linkage.
60 struct D { };
61};
62
Douglas Gregorf57f2072009-12-23 20:51:04 +000063const D getD();
64
65const std::type_info &t2() {
66 (void)typeid(const D);
67 (void)typeid(D *);
68 // CHECK: _ZTIN12_GLOBAL__N_11DE to
69 return typeid(getD());
Anders Carlsson610b0d92009-12-21 00:57:38 +000070}