diff options
author | Patrick Palka <ppalka@redhat.com> | 2023-09-18 14:47:52 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2023-09-18 14:47:52 -0400 |
commit | 6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa (patch) | |
tree | 63f14413d5d7a608b13d93641d832d61ed97a261 /libstdc++-v3/testsuite/26_numerics | |
parent | a6ac1fc64c3caed19da65c2e6b12f8ddaf551231 (diff) | |
download | gcc-6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa.zip gcc-6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa.tar.gz gcc-6e92a6a2a72d3b7a5e1b29042d8a6a43fe1085aa.tar.bz2 |
c++: non-dependent assignment checking [PR63198, PR18474]
This patch makes us recognize and check non-dependent simple assigments
ahead of time, like we already do for compound assignments. This means
the templated representation of such assignments will now usually have
an implicit INDIRECT_REF (due to the reference return type), which the
-Wparentheses code needs to handle. As a drive-by improvement, this
patch also makes maybe_convert_cond issue -Wparentheses warnings ahead
of time, and removes a seemingly unnecessary suppress_warning call in
build_x_modify_expr.
On the libstdc++ side, some tests were attempting to modify a data
member from a uninstantiated const member function, which this patch
minimally fixes by making the data member mutable.
PR c++/63198
PR c++/18474
gcc/cp/ChangeLog:
* semantics.cc (maybe_convert_cond): Look through implicit
INDIRECT_REF when deciding whether to issue a -Wparentheses
warning, and consider templated assignment expressions as well.
(finish_parenthesized_expr): Look through implicit INDIRECT_REF
when suppressing -Wparentheses warning.
* typeck.cc (build_x_modify_expr): Check simple assignments
ahead time too, not just compound assignments. Give the second
operand of MODOP_EXPR a non-null type so that it's not considered
always instantiation-dependent. Don't call suppress_warning.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/static_assert15.C: Expect diagnostic for
non-constant static_assert condition.
* g++.dg/expr/unary2.C: Remove xfails.
* g++.dg/template/init7.C: Make initializer type-dependent to
preserve intent of test.
* g++.dg/template/recurse3.C: Likewise for the erroneous
statement.
* g++.dg/template/non-dependent26.C: New test.
* g++.dg/warn/Wparentheses-32.C: New test.
libstdc++-v3/ChangeLog:
* testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc:
Make data member seed_seq::called mutable.
* testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc:
Likewise.
* testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc:
Likewise.
* testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc:
Likewise.
* testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc:
Likewise.
* testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc:
Likewise.
* testsuite/ext/random/simd_fast_mersenne_twister_engine/cons/seed_seq2.cc:
Likewise.
Diffstat (limited to 'libstdc++-v3/testsuite/26_numerics')
6 files changed, 6 insertions, 6 deletions
diff --git a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc index 720ce96..0d7e667 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type diff --git a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc index f378621..2ef5630 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type diff --git a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc index c1cfe9d..071ed75 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type diff --git a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc index 5247602..2fb9622 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type diff --git a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc index 1ca783e..3fa9c9a 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type diff --git a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc index 08beb3b..25d19a0 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc @@ -51,7 +51,7 @@ struct seed_seq // T is convertible to the engine's result_type: operator T() const noexcept { return T(); } - bool called = false; + mutable bool called = false; }; using engine_type |