150
|
1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple %itanium_abi_triple %s -S -emit-llvm -o - | FileCheck %s
|
|
2 // PR4262
|
|
3
|
|
4 // CHECK-NOT: _ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag
|
|
5
|
|
6 // The "basic_string" extern template instantiation declaration is supposed to
|
|
7 // suppress the implicit instantiation of non-inline member functions. Make sure
|
|
8 // that we suppress the implicit instantiation of non-inline member functions
|
|
9 // defined out-of-line. That we aren't instantiating the basic_string
|
|
10 // constructor when we shouldn't be. Such an instantiation forces the implicit
|
|
11 // instantiation of _S_construct<const char*>. Since _S_construct is a member
|
|
12 // template, it's instantiation is *not* suppressed (despite being in
|
|
13 // basic_string<char>), so we would emit it as a weak definition.
|
|
14
|
|
15 #define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
|
|
16 #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
|
|
17 #define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
|
|
18 #if (__has_feature(cxx_noexcept))
|
|
19 # define _NOEXCEPT noexcept
|
|
20 # define _NOEXCEPT_(x) noexcept(x)
|
|
21 #else
|
|
22 # define _NOEXCEPT throw()
|
|
23 # define _NOEXCEPT_(x)
|
|
24 #endif
|
|
25
|
|
26 namespace std // purposefully not using versioning namespace
|
|
27 {
|
|
28
|
|
29 template<class charT> struct char_traits;
|
|
30 template<class T> class allocator;
|
|
31 template <class _CharT,
|
|
32 class _Traits = char_traits<_CharT>,
|
|
33 class _Allocator = allocator<_CharT> >
|
|
34 class _LIBCPP_VISIBLE basic_string;
|
|
35 typedef basic_string<char, char_traits<char>, allocator<char> > string;
|
|
36
|
|
37 class _LIBCPP_EXCEPTION_ABI exception
|
|
38 {
|
|
39 public:
|
|
40 _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
|
|
41 virtual ~exception() _NOEXCEPT;
|
|
42 virtual const char* what() const _NOEXCEPT;
|
|
43 };
|
|
44
|
|
45 class _LIBCPP_EXCEPTION_ABI runtime_error
|
|
46 : public exception
|
|
47 {
|
|
48 private:
|
|
49 void* __imp_;
|
|
50 public:
|
|
51 explicit runtime_error(const string&);
|
|
52 explicit runtime_error(const char*);
|
|
53
|
|
54 runtime_error(const runtime_error&) _NOEXCEPT;
|
|
55 runtime_error& operator=(const runtime_error&) _NOEXCEPT;
|
|
56
|
|
57 virtual ~runtime_error() _NOEXCEPT;
|
|
58
|
|
59 virtual const char* what() const _NOEXCEPT;
|
|
60 };
|
|
61
|
|
62 }
|
|
63
|
|
64 void dummysymbol() {
|
|
65 throw(std::runtime_error("string"));
|
|
66 }
|
221
|
67
|
|
68 namespace not_weak_on_first {
|
|
69 int func();
|
|
70 // CHECK: {{.*}} extern_weak {{.*}} @_ZN17not_weak_on_first4funcEv(
|
|
71 int func() __attribute__ ((weak));
|
|
72
|
|
73 typedef int (*FuncT)();
|
|
74
|
|
75 extern const FuncT table[] = {
|
|
76 func,
|
|
77 };
|
|
78 }
|
252
|
79
|
|
80 namespace constant_eval {
|
|
81 [[gnu::weak]] extern int a;
|
|
82 // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
|
|
83 // CHECK: store i8 zext (i1 icmp ne (ptr @_ZN13constant_eval1aE, ptr null) to i8), ptr @_ZN13constant_eval6has_a1E,
|
|
84 bool has_a1 = &a;
|
|
85 // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
|
|
86 // CHECK: store i8 zext (i1 icmp ne (ptr @_ZN13constant_eval1aE, ptr null) to i8), ptr @_ZN13constant_eval6has_a2E,
|
|
87 bool has_a2 = &a != nullptr;
|
|
88
|
|
89 struct X {
|
|
90 [[gnu::weak]] void f();
|
|
91 };
|
|
92 // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
|
|
93 // CHECK: store i8 zext (i1 icmp ne (i{{32|64}} ptrtoint (ptr @_ZN13constant_eval1X1fEv to i{{32|64}}), i{{32|64}} 0) to i8), ptr @_ZN13constant_eval6has_f1E,
|
|
94 bool has_f1 = &X::f;
|
|
95 // CHECK-LABEL: define {{.*}} @__cxx_global_var_init
|
|
96 // CHECK: store i8 zext (i1 icmp ne (i{{32|64}} ptrtoint (ptr @_ZN13constant_eval1X1fEv to i{{32|64}}), i{{32|64}} 0) to i8), ptr @_ZN13constant_eval6has_f2E,
|
|
97 bool has_f2 = &X::f != nullptr;
|
|
98 }
|