diff --git a/libcxx/test/libcxx/assertions/single_expression.sh.cpp b/libcxx/test/libcxx/assertions/single_expression.sh.cpp --- a/libcxx/test/libcxx/assertions/single_expression.sh.cpp +++ b/libcxx/test/libcxx/assertions/single_expression.sh.cpp @@ -9,13 +9,13 @@ // Make sure that _LIBCPP_ASSERT is a single expression. This is useful so we can use // it in places that require an expression, such as in a constructor initializer list. -// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=1 +// RUN: %{build} -Wno-macro-redefined -Wno-comma -D_LIBCPP_ENABLE_ASSERTIONS=1 // RUN: %{run} -// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 +// RUN: %{build} -Wno-macro-redefined -Wno-comma -D_LIBCPP_ENABLE_ASSERTIONS=0 // RUN: %{run} -// RUN: %{build} -Wno-macro-redefined -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME +// RUN: %{build} -Wno-macro-redefined -Wno-comma -D_LIBCPP_ENABLE_ASSERTIONS=0 -D_LIBCPP_ASSERTIONS_DISABLE_ASSUME // RUN: %{run} // We flag uses of the assertion handler in older dylibs at compile-time to avoid runtime diff --git a/libcxx/test/libcxx/atomics/bit-int.verify.cpp b/libcxx/test/libcxx/atomics/bit-int.verify.cpp --- a/libcxx/test/libcxx/atomics/bit-int.verify.cpp +++ b/libcxx/test/libcxx/atomics/bit-int.verify.cpp @@ -17,6 +17,8 @@ // UNSUPPORTED: c++03 +// ADDITIONAL_COMPILE_FLAGS: -Wno-bit-int-extension + #include int main(int, char**) diff --git a/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp --- a/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp +++ b/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/move_reentrant.pass.cpp @@ -25,6 +25,8 @@ static std::function global; static bool cancel; + A() = default; + A(const A&) = default; ~A() { DoNotOptimize(cancel); if (cancel) diff --git a/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp --- a/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp +++ b/libcxx/test/libcxx/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign_reentrant.pass.cpp @@ -25,6 +25,8 @@ static std::function global; static bool cancel; + A() = default; + A(const A&) = default; ~A() { DoNotOptimize(cancel); if (cancel) diff --git a/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp --- a/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp +++ b/libcxx/test/std/concepts/concepts.lang/concept.constructible/constructible_from.compile.pass.cpp @@ -106,9 +106,6 @@ test(); test(); test(); - test(); - test(); test(); test(); test); assert(arr[0] == 3); assert(arr[1] == 4); +TEST_DIAGNOSTIC_POP } // Test explicit type. diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iter.ops/back.insert.iter.op=/lv_value.pass.cpp @@ -37,6 +37,7 @@ int data_; public: Copyable() : data_(0) {} + Copyable(const Copyable&) = default; ~Copyable() {data_ = -1;} friend bool operator==(const Copyable& x, const Copyable& y) diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iter.ops/front.insert.iter.op=/lv_value.pass.cpp @@ -37,6 +37,7 @@ int data_; public: Copyable() : data_(0) {} + Copyable(const Copyable&) = default; ~Copyable() {data_ = -1;} friend bool operator==(const Copyable& x, const Copyable& y) diff --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.star/op_star.pass.cpp @@ -25,6 +25,7 @@ int data_; public: A() : data_(1) {} + A(const A&) = default; ~A() {data_ = -1;} friend bool operator==(const A& x, const A& y) diff --git a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.elem/arrow.pass.cpp b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.elem/arrow.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.elem/arrow.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.elem/arrow.pass.cpp @@ -50,6 +50,7 @@ int data_; public: B(int d=1) : data_(d) {} + B(const B&) = default; ~B() {data_ = -1;} int get() const {return data_;} diff --git a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp --- a/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/libcxx/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -28,6 +28,7 @@ int data_; public: explicit A(int data) : data_(data) {} + A(const A&) = default; virtual ~A() TEST_NOEXCEPT {} friend bool operator==(const A& x, const A& y) {return x.data_ == y.data_;} @@ -63,7 +64,6 @@ { A a(3); // not a polymorphic type --> no effect std::rethrow_if_nested(a); - assert(true); } catch (...) { @@ -75,7 +75,6 @@ { D s; // inaccessible base class --> no effect std::rethrow_if_nested(s); - assert(true); } catch (...) { @@ -87,7 +86,6 @@ { E s; // ambiguous base class --> no effect std::rethrow_if_nested(s); - assert(true); } catch (...) { @@ -123,7 +121,6 @@ try { std::rethrow_if_nested(C()); - assert(true); } catch (...) { diff --git a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp --- a/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp +++ b/libcxx/test/std/language.support/support.start.term/quick_exit.pass.cpp @@ -23,5 +23,4 @@ int main(int, char**) { std::at_quick_exit(f); std::quick_exit(0); - return 0; } diff --git a/libcxx/test/std/ranges/range.adaptors/range.drop/dangling.cache.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.drop/dangling.cache.pass.cpp --- a/libcxx/test/std/ranges/range.adaptors/range.drop/dangling.cache.pass.cpp +++ b/libcxx/test/std/ranges/range.adaptors/range.drop/dangling.cache.pass.cpp @@ -30,6 +30,9 @@ constexpr ForwardIter end() { return ForwardIter(buff + 8); } constexpr ForwardIter end() const { return ForwardIter(); } + ZeroOnDestroy() = default; + ZeroOnDestroy(const ZeroOnDestroy&) = default; + ~ZeroOnDestroy() { std::memset(buff, 0, sizeof(buff)); } diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/iterator/singular.pass.cpp b/libcxx/test/std/ranges/range.adaptors/range.zip/iterator/singular.pass.cpp --- a/libcxx/test/std/ranges/range.adaptors/range.zip/iterator/singular.pass.cpp +++ b/libcxx/test/std/ranges/range.adaptors/range.zip/iterator/singular.pass.cpp @@ -31,8 +31,8 @@ ThrowOnIncrementIterator& operator++() { ++it_; throw 5; - return *this; } + void operator++(int) { ++it_; } int& operator*() const { return *it_; } diff --git a/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp b/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp --- a/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.cons/from_range.pass.cpp @@ -161,7 +161,7 @@ struct ThrowingData { char* begin() const { return nullptr; } char* end() const { return nullptr; } - char* data() const { throw 42; return nullptr; } + char* data() const { throw 42; } }; try { ThrowingData x; @@ -174,7 +174,7 @@ struct ThrowingSize { char* begin() const { return nullptr; } char* end() const { return nullptr; } - size_t size() const { throw 42; return 0; } + size_t size() const { throw 42; } }; try { ThrowingSize x; @@ -195,4 +195,3 @@ return 0; } - diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -88,7 +88,6 @@ bool try_lock() { TEST_THROW(1); - return locked_; } void unlock() {locked_ = false;} diff --git a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp --- a/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp +++ b/libcxx/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp @@ -64,7 +64,6 @@ bool try_lock() { TEST_THROW(1); - return locked_; } void unlock() {locked_ = false;} diff --git a/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp b/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp --- a/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp +++ b/libcxx/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp @@ -27,6 +27,7 @@ struct Tracked { static int count; Tracked() {++count;} + Tracked(const Tracked&) = default; ~Tracked() { --count; } }; int Tracked::count = 0; diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -40,6 +40,7 @@ static bool dtor_called; Y() = default; Y(int) { TEST_THROW(6);} + Y(const Y&) = default; ~Y() {dtor_called = true;} }; diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp @@ -31,6 +31,7 @@ constexpr X(int i, bool& dtor_called) : i_(i), dtor_called_(&dtor_called) {} constexpr X(std::initializer_list il, bool& dtor_called) : i_(il.begin()[0]), j_(il.begin()[1]), dtor_called_(&dtor_called) {} + constexpr X(const X&) = default; TEST_CONSTEXPR_CXX20 ~X() {*dtor_called_ = true;} friend constexpr bool operator==(const X& x, const X& y) @@ -57,6 +58,7 @@ public: static bool dtor_called; Z() : i_(0) {} + Z(const Z&) = default; Z(int i) : i_(i) {} Z(std::initializer_list il) : i_(il.begin()[0]), j_(il.begin()[1]) { TEST_THROW(6);} diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp @@ -29,6 +29,7 @@ public: static bool dtor_called; X() = default; + X(const X&) = default; ~X() {dtor_called = true;} }; diff --git a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp --- a/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp +++ b/libcxx/test/std/utilities/optional/optional.object/optional.object.mod/reset.pass.cpp @@ -23,6 +23,8 @@ struct X { static bool dtor_called; + X() = default; + X(const X&) = default; ~X() {dtor_called = true;} }; diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_first.h b/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_first.h --- a/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_first.h +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_first.h @@ -22,6 +22,7 @@ int data_; alloc_first() : data_(0) {} + alloc_first(const alloc_first&) = default; alloc_first(int d) : data_(d) {} alloc_first(std::allocator_arg_t, const A1& a) : data_(0) diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_last.h b/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_last.h --- a/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_last.h +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/alloc_last.h @@ -22,6 +22,7 @@ int data_; alloc_last() : data_(0) {} + alloc_last(const alloc_last&) = default; alloc_last(int d) : data_(d) {} alloc_last(const A1& a) : data_(0) diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp @@ -26,6 +26,8 @@ struct B { int id_; explicit B(int i = 0) : id_(i) {} + B(const B&) = default; + B& operator=(const B&) = default; virtual ~B() {} }; diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp @@ -36,7 +36,7 @@ int id_; explicit B(int i) : id_(i) {} - + B(const B&) = default; virtual ~B() {} }; diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp --- a/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit/visit_return_type.pass.cpp @@ -233,18 +233,18 @@ } } -void test_constexpr_void() { +constexpr bool test_constexpr_void() { constexpr ReturnFirst obj{}; constexpr ReturnArity aobj{}; { using V = std::variant; constexpr V v(42); - static_assert((std::visit(obj, v), 42) == 42, ""); + std::visit(obj, v); } { using V = std::variant; constexpr V v(42l); - static_assert((std::visit(obj, v), 42) == 42, ""); + std::visit(obj, v); } { using V1 = std::variant; @@ -253,7 +253,7 @@ constexpr V1 v1; constexpr V2 v2(nullptr); constexpr V3 v3; - static_assert((std::visit(aobj, v1, v2, v3), 3) == 3, ""); + std::visit(aobj, v1, v2, v3); } { using V1 = std::variant; @@ -262,18 +262,20 @@ constexpr V1 v1; constexpr V2 v2(nullptr); constexpr V3 v3; - static_assert((std::visit(aobj, v1, v2, v3), 3) == 3, ""); + std::visit(aobj, v1, v2, v3); } { using V = std::variant; constexpr V v1(42l), v2(101), v3(nullptr), v4(1.1); - static_assert((std::visit(aobj, v1, v2, v3, v4), 4) == 4, ""); + std::visit(aobj, v1, v2, v3, v4); } { using V = std::variant; constexpr V v1(42l), v2(101), v3(nullptr), v4(1.1); - static_assert((std::visit(aobj, v1, v2, v3, v4), 4) == 4, ""); + std::visit(aobj, v1, v2, v3, v4); } + + return true; } void test_constexpr_int() { @@ -504,7 +506,7 @@ test_call_operator_forwarding(); test_argument_forwarding(); test_return_type(); - test_constexpr_void(); + static_assert(test_constexpr_void()); test_exceptions(); test_caller_accepts_nonconst(); test_call_operator_forwarding(); diff --git a/libcxx/test/support/any_helpers.h b/libcxx/test/support/any_helpers.h --- a/libcxx/test/support/any_helpers.h +++ b/libcxx/test/support/any_helpers.h @@ -286,7 +286,7 @@ throwMyAnyExpression(); } - small_throws_on_copy(small_throws_on_copy && other) throw() { + small_throws_on_copy(small_throws_on_copy && other) noexcept { value = other.value; ++count; ++moved; } @@ -326,7 +326,7 @@ throwMyAnyExpression(); } - large_throws_on_copy(large_throws_on_copy && other) throw() { + large_throws_on_copy(large_throws_on_copy && other) noexcept { value = other.value; ++count; ++moved; } diff --git a/libcxx/test/support/counting_predicates.h b/libcxx/test/support/counting_predicates.h --- a/libcxx/test/support/counting_predicates.h +++ b/libcxx/test/support/counting_predicates.h @@ -18,6 +18,7 @@ typedef bool result_type; unary_counting_predicate(Predicate p) : p_(p), count_(0) {} + unary_counting_predicate(const unary_counting_predicate&) = default; ~unary_counting_predicate() {} bool operator () (const Arg &a) const { ++count_; return p_(a); } diff --git a/libcxx/test/support/deleter_types.h b/libcxx/test/support/deleter_types.h --- a/libcxx/test/support/deleter_types.h +++ b/libcxx/test/support/deleter_types.h @@ -170,6 +170,8 @@ public: CDeleter() : state_(0) {} + CDeleter(const CDeleter&) = default; + CDeleter& operator=(const CDeleter&) = default; explicit CDeleter(int s) : state_(s) {} ~CDeleter() {assert(state_ >= 0); state_ = -1;} @@ -191,6 +193,8 @@ public: CDeleter() : state_(0) {} + CDeleter(const CDeleter&) = default; + CDeleter& operator=(const CDeleter&) = default; explicit CDeleter(int s) : state_(s) {} template CDeleter(const CDeleter& d) diff --git a/libcxx/test/support/nasty_containers.h b/libcxx/test/support/nasty_containers.h --- a/libcxx/test/support/nasty_containers.h +++ b/libcxx/test/support/nasty_containers.h @@ -41,6 +41,8 @@ #if TEST_STD_VER >= 11 nasty_vector(std::initializer_list il) : v_(il) {} #endif + nasty_vector(const nasty_vector&) = default; + nasty_vector& operator=(const nasty_vector&) = default; ~nasty_vector() {} template 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 @@ -7,22 +7,38 @@ #===----------------------------------------------------------------------===## from libcxx.test.dsl import * -from libcxx.test.features import _isMSVC +from libcxx.test.features import _isMSVC, _isClang import re _warningFlags = [ - '-Werror', '-Wall', + '-Walloca', + '-Wcomma', + '-Wdeprecated', '-Wextra', + '-Werror', '-Wshadow', '-Wundef', + '-Wunreachable-code-aggressive', + '-Wvla', + + # GCC doesn't support -Wno-gnu-include-next, so we can't enable -Wpedantic for it + lambda cfg: '-Wpedantic' if _isClang(cfg) else '', + + # We use these extensions in the code base + '-Wno-gnu-include-next', + '-Wno-c11-extensions', + '-Wno-zero-length-array', + '-Wno-unused-command-line-argument', '-Wno-attributes', - '-Wno-pessimizing-move', - '-Wno-c++11-extensions', '-Wno-noexcept-type', '-Wno-aligned-allocation-unavailable', '-Wno-atomic-alignment', + '-Wno-unused-local-typedef', + + # We only support C++03 with Clang extensions + '-Wno-c++11-extensions', # 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. @@ -39,8 +55,6 @@ '-Wsign-compare', '-Wunused-variable', '-Wunused-parameter', - '-Wunreachable-code', - '-Wno-unused-local-typedef', ] _allStandards = ['c++03', 'c++11', 'c++14', 'c++17', 'c++20', 'c++2b']