From: Jonathan Wakely Date: Thu, 2 May 2019 21:23:38 +0000 (+0100) Subject: PR libstdc++/90314 fix non-equivalent declarations of std::swap X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=315f8b5f18dcfcd81401c9629deaf77443fa7c1e;p=gcc.git PR libstdc++/90314 fix non-equivalent declarations of std::swap In order to use the _GLIBCXX_NOEXCEPT_IF macro for an expression containing commas I enclosed it in parentheses, so the preprocessor wouldn't treat it as two arguments to the function-like macro. Clang gives an error because now the noexcept-specifier noexcept((C)) is not equivalent to the noexcept(C) one on the declaration of swap in . Instead of requiring extra parentheses around the expression, redefine _GLIBCXX_NOEXCEPT_IF as a variadic macro (even though supporting that in C++98 is a GNU extension). PR libstdc++/90314 * include/bits/c++config (_GLIBCXX_NOEXCEPT_IF): Use variadic macro. * include/bits/move.h (swap): Remove extra parentheses. From-SVN: r270827 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index cd1508ee789..6c93604d318 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2019-05-02 Jonathan Wakely + PR libstdc++/90314 + * include/bits/c++config (_GLIBCXX_NOEXCEPT_IF): Use variadic macro. + * include/bits/move.h (swap): Remove extra parentheses. + * include/experimental/bits/lfts_config.h: Improve doc markup. * include/experimental/optional: Improve docs. (_Has_addressof_mem, _Has_addressof_free, _Has_addressof) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 5016f4853de..ca1557af564 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -157,12 +157,12 @@ #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L # define _GLIBCXX_NOEXCEPT noexcept -# define _GLIBCXX_NOEXCEPT_IF(_COND) noexcept(_COND) +# define _GLIBCXX_NOEXCEPT_IF(...) noexcept(__VA_ARGS__) # define _GLIBCXX_USE_NOEXCEPT noexcept # define _GLIBCXX_THROW(_EXC) # else # define _GLIBCXX_NOEXCEPT -# define _GLIBCXX_NOEXCEPT_IF(_COND) +# define _GLIBCXX_NOEXCEPT_IF(...) # define _GLIBCXX_USE_NOEXCEPT throw() # define _GLIBCXX_THROW(_EXC) throw(_EXC) # endif diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h index 996078cfbce..7271e273e8e 100644 --- a/libstdc++-v3/include/bits/move.h +++ b/libstdc++-v3/include/bits/move.h @@ -183,8 +183,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void #endif swap(_Tp& __a, _Tp& __b) - _GLIBCXX_NOEXCEPT_IF((__and_, - is_nothrow_move_assignable<_Tp>>::value)) + _GLIBCXX_NOEXCEPT_IF(__and_, + is_nothrow_move_assignable<_Tp>>::value) { // concept requirements __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)