1abea951c34876a5374d0e3678c7989b225c5c895Anders Carlsson// RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
29dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
3f502d93b0ea970bfbd897e657f8d940a20984de2Anders Carlsson// CHECK: @_ZTIN5test11AE = linkonce_odr unnamed_addr constant
4f502d93b0ea970bfbd897e657f8d940a20984de2Anders Carlsson// CHECK: @_ZTIN5test11BE = linkonce_odr unnamed_addr constant
5f502d93b0ea970bfbd897e657f8d940a20984de2Anders Carlsson// CHECK: @_ZTIN5test11CE = linkonce_odr unnamed_addr constant
6f502d93b0ea970bfbd897e657f8d940a20984de2Anders Carlsson// CHECK: @_ZTIN5test11DE = linkonce_odr unnamed_addr constant
7f502d93b0ea970bfbd897e657f8d940a20984de2Anders Carlsson// CHECK: @_ZTIPN5test11DE = linkonce_odr unnamed_addr constant {{.*}} @_ZTIN5test11DE
89dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
99dffe6f51c676c1e423c382c62d1648746e36cd4John McCall// PR6974: this shouldn't crash
109dffe6f51c676c1e423c382c62d1648746e36cd4John McCallnamespace test0 {
119dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  class err {};
129dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
139dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void f(void) {
149dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    try {
159dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    } catch (err &) {
169dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    }
179dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  }
189dffe6f51c676c1e423c382c62d1648746e36cd4John McCall}
199dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
209dffe6f51c676c1e423c382c62d1648746e36cd4John McCallnamespace test1 {
21cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // These classes have key functions defined out-of-line.  Under
22cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // normal circumstances, we wouldn't generate RTTI for them; under
23cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // -fno-rtti, we generate RTTI only when required by EH.  But
24cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // everything gets hidden visibility because we assume that all
25cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // users are also compiled under -fno-rtti and therefore will be
26cbfe50224b19119e759802bd0c1463269dffd09eJohn McCall  // emitting RTTI regardless of key function.
279dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  class A { virtual void foo(); };
289dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  class B { virtual void foo(); };
299dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  class C { virtual void foo(); };
309dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  class D { virtual void foo(); };
319dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
329dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void opaque();
339dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
349dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void test0() {
359dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    throw A();
369dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  }
379dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
389dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void test1() throw(B) {
399dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    opaque();
409dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  }
419dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
429dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void test2() {
439dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    try {
449dffe6f51c676c1e423c382c62d1648746e36cd4John McCall      opaque();
459dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    } catch (C&) {}
469dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  }
479dffe6f51c676c1e423c382c62d1648746e36cd4John McCall
489dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  void test3(D *ptr) {
499dffe6f51c676c1e423c382c62d1648746e36cd4John McCall    throw ptr;
509dffe6f51c676c1e423c382c62d1648746e36cd4John McCall  };
519dffe6f51c676c1e423c382c62d1648746e36cd4John McCall}
52