1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple %itanium_abi_triple %s -S -emit-llvm -o - | FileCheck %s
4 // CHECK-NOT: _ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag
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.
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)
22 # define _NOEXCEPT throw()
23 # define _NOEXCEPT_(x)
26 namespace std
// purposefully not using versioning namespace
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
;
37 class _LIBCPP_EXCEPTION_ABI exception
40 _LIBCPP_INLINE_VISIBILITY
exception() _NOEXCEPT
{}
41 virtual ~exception() _NOEXCEPT
;
42 virtual const char* what() const _NOEXCEPT
;
45 class _LIBCPP_EXCEPTION_ABI runtime_error
51 explicit runtime_error(const string
&);
52 explicit runtime_error(const char*);
54 runtime_error(const runtime_error
&) _NOEXCEPT
;
55 runtime_error
& operator=(const runtime_error
&) _NOEXCEPT
;
57 virtual ~runtime_error() _NOEXCEPT
;
59 virtual const char* what() const _NOEXCEPT
;
65 throw(std::runtime_error("string"));
68 namespace not_weak_on_first
{
70 // CHECK: {{.*}} extern_weak {{.*}} @_ZN17not_weak_on_first4funcEv(
71 int func() __attribute__ ((weak
));
73 typedef int (*FuncT
)();
75 extern const FuncT table
[] = {
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,
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;
90 [[gnu::weak
]] void f();
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,
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;