mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
refactor: disable self-assign warning for tests
clang-16 and earlier detect "foo -= foo" and "foo /= foo" as self-assignments.
This commit is contained in:
@@ -43,7 +43,19 @@ FUZZ_TARGET(muhash)
|
|||||||
},
|
},
|
||||||
[&] {
|
[&] {
|
||||||
// Test that dividing a MuHash by itself brings it back to it's initial state
|
// Test that dividing a MuHash by itself brings it back to it's initial state
|
||||||
|
|
||||||
|
// See note about clang + self-assignment in test/uint256_tests.cpp
|
||||||
|
#if defined(__clang__)
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
|
||||||
|
#endif
|
||||||
|
|
||||||
muhash /= muhash;
|
muhash /= muhash;
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
muhash.Finalize(out);
|
muhash.Finalize(out);
|
||||||
out2 = uint256S(initial_state_hash);
|
out2 = uint256S(initial_state_hash);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -267,6 +267,22 @@ BOOST_AUTO_TEST_CASE( conversion )
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE( operator_with_self )
|
BOOST_AUTO_TEST_CASE( operator_with_self )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* Clang 16 and earlier detects v -= v and v /= v as self-assignments
|
||||||
|
to 0 and 1 respectively.
|
||||||
|
See: https://github.com/llvm/llvm-project/issues/42469
|
||||||
|
and the fix in commit c5302325b2a62d77cf13dd16cd5c19141862fed0 .
|
||||||
|
|
||||||
|
This makes some sense for arithmetic classes, but could be considered a bug
|
||||||
|
elsewhere. Disable the warning here so that the code can be tested, but the
|
||||||
|
warning should remain on as there will likely always be a better way to
|
||||||
|
express this.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
# pragma clang diagnostic push
|
||||||
|
# pragma clang diagnostic ignored "-Wself-assign-overloaded"
|
||||||
|
#endif
|
||||||
arith_uint256 v = UintToArith256(uint256S("02"));
|
arith_uint256 v = UintToArith256(uint256S("02"));
|
||||||
v *= v;
|
v *= v;
|
||||||
BOOST_CHECK(v == UintToArith256(uint256S("04")));
|
BOOST_CHECK(v == UintToArith256(uint256S("04")));
|
||||||
@@ -276,6 +292,9 @@ BOOST_AUTO_TEST_CASE( operator_with_self )
|
|||||||
BOOST_CHECK(v == UintToArith256(uint256S("02")));
|
BOOST_CHECK(v == UintToArith256(uint256S("02")));
|
||||||
v -= v;
|
v -= v;
|
||||||
BOOST_CHECK(v == UintToArith256(uint256S("0")));
|
BOOST_CHECK(v == UintToArith256(uint256S("0")));
|
||||||
|
#if defined(__clang__)
|
||||||
|
# pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(parse)
|
BOOST_AUTO_TEST_CASE(parse)
|
||||||
|
|||||||
Reference in New Issue
Block a user