diff --git a/libcxx/include/__algorithm/copy.h b/libcxx/include/__algorithm/copy.h --- a/libcxx/include/__algorithm/copy.h +++ b/libcxx/include/__algorithm/copy.h @@ -53,7 +53,7 @@ { const size_t __n = static_cast(__last - __first); if (__n > 0) - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + _VSTD::memmove(static_cast(__result), static_cast(__first), __n * sizeof(_Up)); return __result + __n; } diff --git a/libcxx/include/__algorithm/copy_backward.h b/libcxx/include/__algorithm/copy_backward.h --- a/libcxx/include/__algorithm/copy_backward.h +++ b/libcxx/include/__algorithm/copy_backward.h @@ -53,7 +53,7 @@ if (__n > 0) { __result -= __n; - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + _VSTD::memmove(static_cast(__result), static_cast(__first), __n * sizeof(_Up)); } return __result; } diff --git a/libcxx/include/__algorithm/move.h b/libcxx/include/__algorithm/move.h --- a/libcxx/include/__algorithm/move.h +++ b/libcxx/include/__algorithm/move.h @@ -53,7 +53,7 @@ { const size_t __n = static_cast(__last - __first); if (__n > 0) - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + _VSTD::memmove(static_cast(__result), static_cast(__first), __n * sizeof(_Up)); return __result + __n; } diff --git a/libcxx/include/__algorithm/move_backward.h b/libcxx/include/__algorithm/move_backward.h --- a/libcxx/include/__algorithm/move_backward.h +++ b/libcxx/include/__algorithm/move_backward.h @@ -53,7 +53,7 @@ if (__n > 0) { __result -= __n; - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + _VSTD::memmove(static_cast(__result), static_cast(__first), __n * sizeof(_Up)); } return __result; } diff --git a/libcxx/include/__iterator/size.h b/libcxx/include/__iterator/size.h --- a/libcxx/include/__iterator/size.h +++ b/libcxx/include/__iterator/size.h @@ -41,9 +41,14 @@ -> common_type_t> { return static_cast>>(__c.size()); } +// GCC complains about the implicit conversion from ptrdiff_t to size_t in +// the array bound. +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wsign-conversion") template _LIBCPP_INLINE_VISIBILITY constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } +_LIBCPP_DIAGNOSTIC_POP #endif #endif // _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/any b/libcxx/include/any --- a/libcxx/include/any +++ b/libcxx/include/any @@ -364,6 +364,7 @@ case _Action::_TypeInfo: return __type_info(); } + __libcpp_unreachable(); } template @@ -447,6 +448,7 @@ case _Action::_TypeInfo: return __type_info(); } + __libcpp_unreachable(); } template diff --git a/libcxx/include/barrier b/libcxx/include/barrier --- a/libcxx/include/barrier +++ b/libcxx/include/barrier @@ -123,10 +123,10 @@ } _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY - __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) + __barrier_base(ptrdiff_t __expected, _CompletionF __completion_func = _CompletionF()) : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected), &__destroy_barrier_algorithm_base), - __expected_adjustment(0), __completion(std::move(__completion)), __phase(0) + __expected_adjustment(0), __completion(std::move(__completion_func)), __phase(0) { } [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/experimental/simd b/libcxx/include/experimental/simd --- a/libcxx/include/experimental/simd +++ b/libcxx/include/experimental/simd @@ -1470,6 +1470,8 @@ simd operator+() const; simd operator-() const; + _LIBCPP_DIAGNOSTIC_PUSH + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wnon-template-friend") // binary operators [simd.binary] friend simd operator+(const simd&, const simd&); friend simd operator-(const simd&, const simd&); @@ -1506,6 +1508,7 @@ friend mask_type operator<=(const simd&, const simd&); friend mask_type operator>(const simd&, const simd&); friend mask_type operator<(const simd&, const simd&); + _LIBCPP_DIAGNOSTIC_POP }; // [simd.mask.class] @@ -1545,6 +1548,8 @@ // unary operators [simd.mask.unary] simd_mask operator!() const noexcept; + _LIBCPP_DIAGNOSTIC_PUSH + _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wnon-template-friend") // simd_mask binary operators [simd.mask.binary] friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; @@ -1560,6 +1565,7 @@ // simd_mask compares [simd.mask.comparison] friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; + _LIBCPP_DIAGNOSTIC_POP }; #endif // _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/latch b/libcxx/include/latch --- a/libcxx/include/latch +++ b/libcxx/include/latch @@ -91,7 +91,7 @@ inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY void wait() const { - auto const __test_fn = [=]() -> bool { + auto const __test_fn = [this]() -> bool { return try_wait(); }; __cxx_atomic_wait(&__a.__a_, __test_fn); diff --git a/libcxx/include/memory b/libcxx/include/memory --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -906,7 +906,7 @@ void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) { ptrdiff_t _Np = __end1 - __begin1; if (_Np > 0) { - _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest)); + _VSTD::memcpy(static_cast(__begin2), static_cast(__begin1), _Np * sizeof(_Dest)); __begin2 += _Np; } } diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -2094,14 +2094,14 @@ { typedef __owns_one_state<_CharT> base; - bool __multiline; + bool __multiline_; public: typedef _VSTD::__state<_CharT> __state; _LIBCPP_INLINE_VISIBILITY __r_anchor_multiline(bool __multiline, __node<_CharT>* __s) - : base(__s), __multiline(__multiline) {} + : base(__s), __multiline_(__multiline) {} virtual void __exec(__state&) const; }; @@ -2116,7 +2116,7 @@ __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); } - else if (__multiline && __is_eol(*__s.__current_)) + else if (__multiline_ && __is_eol(*__s.__current_)) { __s.__do_ = __state::__accept_but_not_consume; __s.__node_ = this->first(); diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -2300,7 +2300,7 @@ basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( const value_type* __s, size_type __n) { - size_type __cap = __is_short ? __min_cap : __get_long_cap(); + size_type __cap = __is_short ? static_cast(__min_cap) : __get_long_cap(); if (__n < __cap) { pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); __is_short ? __set_short_size(__n) : __set_long_size(__n); diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -2332,7 +2332,7 @@ void __vdeallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY static size_type __align_it(size_type __new_size) _NOEXCEPT - {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);} + {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);} _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); template diff --git a/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp --- a/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.lang/concept.default.init/default_initializable.compile.pass.cpp @@ -9,6 +9,10 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 // UNSUPPORTED: libcpp-no-concepts +// We voluntarily use std::default_initializable on types that have redundant +// or ignored cv-qualifiers -- don't warn about it. +// ADDITIONAL_COMPILE_FLAGS: -Wno-ignored-qualifiers + // template // concept default_initializable = constructible_from && // requires { T{}; } && diff --git a/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp b/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp --- a/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.object/movable.compile.pass.cpp @@ -74,7 +74,6 @@ static_assert(std::movable > >); static_assert(std::movable >); -static_assert(std::movable); static_assert(std::movable); static_assert(std::movable); @@ -110,9 +109,9 @@ static_assert(std::movable); static_assert(!std::movable); -static_assert(!std::assignable_from); -static_assert(!std::movable); +static_assert(!std::assignable_from); +static_assert(!std::movable); static_assert(!std::movable); static_assert(std::movable); diff --git a/libcxx/test/support/type_classification/movable.h b/libcxx/test/support/type_classification/movable.h --- a/libcxx/test/support/type_classification/movable.h +++ b/libcxx/test/support/type_classification/movable.h @@ -66,14 +66,10 @@ not_quite_multi_param_move_ctor& operator=(not_quite_multi_param_move_ctor&&); }; -struct traditional_copy_assignment_only { - traditional_copy_assignment_only& - operator=(traditional_copy_assignment_only const&); -}; - -struct copy_assign_with_mutable_parameter { - copy_assign_with_mutable_parameter& - operator=(copy_assign_with_mutable_parameter&); +struct copy_with_mutable_parameter { + copy_with_mutable_parameter(copy_with_mutable_parameter&); + copy_with_mutable_parameter& + operator=(copy_with_mutable_parameter&); }; struct const_move_assignment { diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py --- a/libcxx/utils/libcxx/test/features.py +++ b/libcxx/utils/libcxx/test/features.py @@ -123,13 +123,15 @@ Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)), when=_isAppleClang), Feature(name=lambda cfg: 'apple-clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}'.format(**compilerMacros(cfg)), when=_isAppleClang), - Feature(name='clang', when=_isClang, - actions=[AddCompileFlag('-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER')]), + Feature(name='clang', when=_isClang), Feature(name=lambda cfg: 'clang-{__clang_major__}'.format(**compilerMacros(cfg)), when=_isClang), Feature(name=lambda cfg: 'clang-{__clang_major__}.{__clang_minor__}'.format(**compilerMacros(cfg)), when=_isClang), Feature(name=lambda cfg: 'clang-{__clang_major__}.{__clang_minor__}.{__clang_patchlevel__}'.format(**compilerMacros(cfg)), when=_isClang), - Feature(name='gcc', when=_isGCC), + # Note: Due to a GCC bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104760), we must disable deprecation warnings + # on GCC or spurious diagnostics are issued. + Feature(name='gcc', when=_isGCC, + actions=[AddCompileFlag('-D_LIBCPP_DISABLE_DEPRECATION_WARNINGS')]), Feature(name=lambda cfg: 'gcc-{__GNUC__}'.format(**compilerMacros(cfg)), when=_isGCC), Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}'.format(**compilerMacros(cfg)), when=_isGCC), Feature(name=lambda cfg: 'gcc-{__GNUC__}.{__GNUC_MINOR__}.{__GNUC_PATCHLEVEL__}'.format(**compilerMacros(cfg)), when=_isGCC), diff --git a/libcxx/utils/libcxx/test/params.py b/libcxx/utils/libcxx/test/params.py --- a/libcxx/utils/libcxx/test/params.py +++ b/libcxx/utils/libcxx/test/params.py @@ -14,21 +14,25 @@ '-Werror', '-Wall', '-Wextra', - '-Wshadow', '-Wundef', '-Wno-unused-command-line-argument', '-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extensions', - '-Wno-user-defined-literals', '-Wno-noexcept-type', '-Wno-aligned-allocation-unavailable', '-Wno-atomic-alignment', + '-Wno-shadow', # GCC warns about places where we might want to add sized allocation/deallocation # functions, but we know better what we're doing/testing in the test suite. '-Wno-sized-deallocation', + # Turn off warnings about user-defined literals with reserved suffixes. Those are + # just noise since we are testing the Standard Library itself. + '-Wno-literal-suffix', # GCC + '-Wno-user-defined-literals', # Clang + # These warnings should be enabled in order to support the MSVC # team using the test suite; They enable the warnings below and # expect the test suite to be clean. @@ -118,9 +122,10 @@ Parameter(name='enable_warnings', choices=[True, False], type=bool, default=True, help="Whether to enable warnings when compiling the test suite.", - actions=lambda warnings: [] if not warnings else [ - AddOptionalWarningFlag(w) for w in _warningFlags - ]), + actions=lambda warnings: [] if not warnings else + [AddOptionalWarningFlag(w) for w in _warningFlags] + + [AddCompileFlag('-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER')] + ), Parameter(name='debug_level', choices=['', '0', '1'], type=str, default='', help="The debugging level to enable in the test suite.",