VirtualBox

Changeset 85069 in vbox for trunk


Ignore:
Timestamp:
Jul 6, 2020 1:01:22 PM (4 years ago)
Author:
vboxsync
Message:

iprt/cdefs.h: Map RT_NO_THROW_PROTO/DEF onto noexcept when possible as throw() is being redefined in c++17 to involve terminate. Also, Clang (11 at least) get upset when we use nothrow on the prototype but not on the definition and we'd need a DECL_NO_THROW for putthe the nothrow attribute in the right place on a definition, which is too much work right now. bugref:9790

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cdefs.h

    r84527 r85069  
    231231 * @param   a_MinMinor      The minor version number part.
    232232 */
    233 #define RT_CLANG_PREREQ(a_MinMajor, a_MinMinor)      RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
     233#define RT_CLANG_PREREQ(a_MinMajor, a_MinMinor)     RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, 0)
    234234/** @def RT_CLANG_PREREQ_EX
    235235 * Simplified way of checking __clang_major__ and __clang_minor__ regardless of
     
    245245#else
    246246# define RT_CLANG_PREREQ_EX(a_MinMajor, a_MinMinor, a_OtherRet) (a_OtherRet)
     247#endif
     248/** @def RT_CLANG_HAS_FEATURE
     249 * Wrapper around clang's __has_feature().
     250 *
     251 * @param   a_Feature       The feature to check for.
     252 */
     253#if defined(__clang_major__) && defined(__clang_minor__) && defined(__has_feature)
     254# define RT_CLANG_HAS_FEATURE(a_Feature)            (__has_feature(a_Feature))
     255#else
     256# define RT_CLANG_HAS_FEATURE(a_Feature)            (0)
    247257#endif
    248258
     
    10631073
    10641074/** @def RT_NO_THROW_PROTO
    1065  * How to express that a function doesn't throw C++ exceptions
    1066  * and the compiler can thus save itself the bother of trying
    1067  * to catch any of them. Put this between the closing parenthesis
    1068  * and the semicolon in function prototypes (and implementation if C++).
     1075 * How to express that a function doesn't throw C++ exceptions and the compiler
     1076 * can thus save itself the bother of trying to catch any of them and generate
     1077 * unwind info.  Put this between the closing parenthesis and the semicolon in
     1078 * function prototypes (and implementation if C++).
    10691079 *
    10701080 * @remarks May not work on C++ methods, mainly intented for C-style APIs.
     
    10751085 *          macros, as the nothrow attribute is not for the function definition.
    10761086 */
     1087/** @def RT_NO_THROW_DEF
     1088 * The counter part to RT_NO_THROW_PROTO that is added to the function
     1089 * definition.
     1090 */
    10771091#ifdef RT_EXCEPTIONS_ENABLED
    1078 # ifdef __GNUC__
     1092# if RT_MSC_PREREQ_EX(RT_MSC_VER_VS2015, 0) \
     1093  || RT_CLANG_HAS_FEATURE(cxx_noexcept) \
     1094  || (RT_GNUC_PREREQ(7, 0) && __cplusplus >= 201100)
     1095#  define RT_NO_THROW_PROTO     noexcept
     1096#  define RT_NO_THROW_DEF       noexcept
     1097# elif defined(__GNUC__)
    10791098#  if RT_GNUC_PREREQ(3, 3)
    10801099#   define RT_NO_THROW_PROTO    __attribute__((__nothrow__))
     
    10821101#   define RT_NO_THROW_PROTO
    10831102#  endif
     1103#  define RT_NO_THROW_DEF       /* Would need a DECL_NO_THROW like __declspec(nothrow), which we wont do at this point. */
    10841104# else
    10851105#  define RT_NO_THROW_PROTO     throw()
     1106#  define RT_NO_THROW_DEF       throw()
    10861107# endif
    10871108#else
    10881109# define RT_NO_THROW_PROTO
    1089 #endif
    1090 
    1091 /** @def RT_NO_THROW_DEF
    1092  * The counter part to RT_NO_THROW_PROTO that is added to the function
    1093  * definition.
    1094  */
    1095 #if defined(RT_EXCEPTIONS_ENABLED) && !defined(__GNUC__)
    1096 # define RT_NO_THROW_DEF        RT_NO_THROW_PROTO
    1097 #else
    10981110# define RT_NO_THROW_DEF
    10991111#endif
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette