16774b1f1SAnders Carlsson // RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
248bf3494SJohn McCall 
3*57420b32SJohn McCall // CHECK: @_ZTIN5test11AE = linkonce_odr constant
4*57420b32SJohn McCall // CHECK: @_ZTIN5test11BE = linkonce_odr constant
5*57420b32SJohn McCall // CHECK: @_ZTIN5test11CE = linkonce_odr constant
6*57420b32SJohn McCall // CHECK: @_ZTIN5test11DE = linkonce_odr constant
7*57420b32SJohn McCall // CHECK: @_ZTIPN5test11DE = linkonce_odr constant {{.*}} @_ZTIN5test11DE
848bf3494SJohn McCall 
948bf3494SJohn McCall // PR6974: this shouldn't crash
1048bf3494SJohn McCall namespace test0 {
1148bf3494SJohn McCall   class err {};
1248bf3494SJohn McCall 
f(void)1348bf3494SJohn McCall   void f(void) {
1448bf3494SJohn McCall     try {
1548bf3494SJohn McCall     } catch (err &) {
1648bf3494SJohn McCall     }
1748bf3494SJohn McCall   }
1848bf3494SJohn McCall }
1948bf3494SJohn McCall 
2048bf3494SJohn McCall namespace test1 {
21e16adc2bSJohn McCall   // These classes have key functions defined out-of-line.  Under
22e16adc2bSJohn McCall   // normal circumstances, we wouldn't generate RTTI for them; under
23e16adc2bSJohn McCall   // -fno-rtti, we generate RTTI only when required by EH.  But
24e16adc2bSJohn McCall   // everything gets hidden visibility because we assume that all
25e16adc2bSJohn McCall   // users are also compiled under -fno-rtti and therefore will be
26e16adc2bSJohn McCall   // emitting RTTI regardless of key function.
2748bf3494SJohn McCall   class A { virtual void foo(); };
2848bf3494SJohn McCall   class B { virtual void foo(); };
2948bf3494SJohn McCall   class C { virtual void foo(); };
3048bf3494SJohn McCall   class D { virtual void foo(); };
3148bf3494SJohn McCall 
3248bf3494SJohn McCall   void opaque();
3348bf3494SJohn McCall 
test0()3448bf3494SJohn McCall   void test0() {
3548bf3494SJohn McCall     throw A();
3648bf3494SJohn McCall   }
3748bf3494SJohn McCall 
test1()3848bf3494SJohn McCall   void test1() throw(B) {
3948bf3494SJohn McCall     opaque();
4048bf3494SJohn McCall   }
4148bf3494SJohn McCall 
test2()4248bf3494SJohn McCall   void test2() {
4348bf3494SJohn McCall     try {
4448bf3494SJohn McCall       opaque();
4548bf3494SJohn McCall     } catch (C&) {}
4648bf3494SJohn McCall   }
4748bf3494SJohn McCall 
test3(D * ptr)4848bf3494SJohn McCall   void test3(D *ptr) {
4948bf3494SJohn McCall     throw ptr;
5048bf3494SJohn McCall   };
5148bf3494SJohn McCall }
52