From 4b7a43da34a986ad356993d9ccea8c99a45a958a Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 26 May 2011 17:07:32 +0000 Subject: [PATCH] Added [[noreturn]] attribute everywhere it should be git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@132125 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__config | 6 ++++-- include/exception | 16 +++++++++------- src/exception.cpp | 6 ++++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/__config b/include/__config index ef03e62b..48f3a440 100644 --- a/include/__config +++ b/include/__config @@ -116,8 +116,10 @@ typedef __char32_t char32_t; #define _LIBCPP_HAS_NO_DECLTYPE #endif -#if !(__has_feature(cxx_attributes)) -#define _LIBCPP_HAS_NO_ATTRIBUTES +#if __has_feature(cxx_attributes) +# define _ATTRIBUTE(x) [[x]] +#else +# define _ATTRIBUTE(x) __attribute__ ((x)) #endif #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS diff --git a/include/exception b/include/exception index 4871f413..87f6552a 100644 --- a/include/exception +++ b/include/exception @@ -105,19 +105,19 @@ public: typedef void (*unexpected_handler)(); _LIBCPP_VISIBLE unexpected_handler set_unexpected(unexpected_handler) throw(); _LIBCPP_VISIBLE unexpected_handler get_unexpected() throw(); -_LIBCPP_VISIBLE void unexpected(); +_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void unexpected(); typedef void (*terminate_handler)(); _LIBCPP_VISIBLE terminate_handler set_terminate(terminate_handler) throw(); _LIBCPP_VISIBLE terminate_handler get_terminate() throw(); -_LIBCPP_VISIBLE void terminate() __attribute__((__noreturn__)); +_ATTRIBUTE(noreturn) _LIBCPP_VISIBLE void terminate() _NOEXCEPT; _LIBCPP_VISIBLE bool uncaught_exception() throw(); class exception_ptr; exception_ptr current_exception(); -void rethrow_exception(exception_ptr); // noreturn +_ATTRIBUTE(noreturn) void rethrow_exception(exception_ptr); class _LIBCPP_VISIBLE exception_ptr { @@ -141,7 +141,7 @@ public: {return !(__x == __y);} friend exception_ptr current_exception(); - friend void rethrow_exception(exception_ptr); // noreturn + _ATTRIBUTE(noreturn) friend void rethrow_exception(exception_ptr); }; template @@ -172,7 +172,7 @@ public: virtual ~nested_exception(); // access functions - void rethrow_nested /*[[noreturn]]*/ () const; + _ATTRIBUTE(noreturn) void rethrow_nested() const; _LIBCPP_INLINE_VISIBILITY exception_ptr nested_ptr() const {return __ptr_;} }; @@ -185,9 +185,10 @@ struct __nested }; template +_ATTRIBUTE(noreturn) void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -throw_with_nested /*[[noreturn]]*/ (_Tp&& __t, typename enable_if< +throw_with_nested(_Tp&& __t, typename enable_if< is_class::type>::value && !is_base_of::type>::value >::type* = 0) @@ -203,9 +204,10 @@ throw_with_nested (_Tp& __t, typename enable_if< } template +_ATTRIBUTE(noreturn) void #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -throw_with_nested /*[[noreturn]]*/ (_Tp&& __t, typename enable_if< +throw_with_nested(_Tp&& __t, typename enable_if< !is_class::type>::value || is_base_of::type>::value >::type* = 0) diff --git a/src/exception.cpp b/src/exception.cpp index 4d4caf4b..42d0721c 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -35,6 +35,7 @@ std::get_unexpected() throw() return __sync_fetch_and_add(&__unexpected_handler, (std::unexpected_handler)0); } +_ATTRIBUTE(noreturn) void std::unexpected() { @@ -56,7 +57,7 @@ std::get_terminate() throw() } void -std::terminate() +std::terminate() _NOEXCEPT { #ifndef _LIBCPP_NO_EXCEPTIONS try @@ -156,8 +157,9 @@ nested_exception::~nested_exception() { } +_ATTRIBUTE(noreturn) void -nested_exception::rethrow_nested /*[[noreturn]]*/ () const +nested_exception::rethrow_nested() const { if (__ptr_ == nullptr) terminate();