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
<type_traits>.

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
This commit is contained in:
Jonathan Wakely 2019-05-02 22:23:38 +01:00 committed by Jonathan Wakely
parent b752e2c926
commit 315f8b5f18
3 changed files with 8 additions and 4 deletions

View file

@ -1,5 +1,9 @@
2019-05-02 Jonathan Wakely <jwakely@redhat.com>
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)

View file

@ -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

View file

@ -183,8 +183,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
#endif
swap(_Tp& __a, _Tp& __b)
_GLIBCXX_NOEXCEPT_IF((__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>::value))
_GLIBCXX_NOEXCEPT_IF(__and_<is_nothrow_move_constructible<_Tp>,
is_nothrow_move_assignable<_Tp>>::value)
{
// concept requirements
__glibcxx_function_requires(_SGIAssignableConcept<_Tp>)