141f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// RUN: %clang -fexceptions %s -S -emit-llvm -o - | FileCheck %s
241f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// PR4262
341f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher
441f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// CHECK-NOT: _ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag
541f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher
641f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// The "basic_string" extern template instantiation declaration is supposed to
741f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// suppress the implicit instantiation of non-inline member functions. Make sure
841f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// that we suppress the implicit instantiation of non-inline member functions
941f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// defined out-of-line. That we aren't instantiating the basic_string
1041f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// constructor when we shouldn't be. Such an instantiation forces the implicit
1141f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// instantiation of _S_construct<const char*>. Since _S_construct is a member
1241f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// template, it's instantiation is *not* suppressed (despite being in
1341f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher// basic_string<char>), so we would emit it as a weak definition.
1441f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher
151999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
161999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
171999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#define _LIBCPP_VISIBLE __attribute__ ((__visibility__("default")))
181999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#if (__has_feature(cxx_noexcept))
191999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#  define _NOEXCEPT noexcept
201999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#  define _NOEXCEPT_(x) noexcept(x)
211999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#else
221999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#  define _NOEXCEPT throw()
231999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#  define _NOEXCEPT_(x)
241999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky#endif
251999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
261999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckynamespace std  // purposefully not using versioning namespace
271999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky{
281999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
291999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckytemplate<class charT> struct char_traits;
301999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckytemplate<class T>     class allocator;
311999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckytemplate <class _CharT,
321999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky          class _Traits = char_traits<_CharT>,
331999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky          class _Allocator = allocator<_CharT> >
341999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    class _LIBCPP_VISIBLE basic_string;
351999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckytypedef basic_string<char, char_traits<char>, allocator<char> > string;
361999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
371999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckyclass _LIBCPP_EXCEPTION_ABI exception
381999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky{
391999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckypublic:
401999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
411999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    virtual ~exception() _NOEXCEPT;
421999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    virtual const char* what() const _NOEXCEPT;
431999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky};
441999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
451999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckyclass _LIBCPP_EXCEPTION_ABI runtime_error
461999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    : public exception
471999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky{
481999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckyprivate:
491999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    void* __imp_;
501999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewyckypublic:
511999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    explicit runtime_error(const string&);
521999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    explicit runtime_error(const char*);
531999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
541999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    runtime_error(const runtime_error&) _NOEXCEPT;
551999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    runtime_error& operator=(const runtime_error&) _NOEXCEPT;
561999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
571999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    virtual ~runtime_error() _NOEXCEPT;
581999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
591999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky    virtual const char* what() const _NOEXCEPT;
601999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky};
611999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky
621999c7c8fa8393e0986b12328b2366a18d6038ffNick Lewycky}
6341f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher
6441f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christophervoid dummysymbol() {
6541f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher  throw(std::runtime_error("string"));
6641f001f0fcb665dd83fe19776fb1fb9997a1a242Eric Christopher}
67