aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop-manip.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-12-21 15:00:55 -0500
committerPatrick Palka <ppalka@redhat.com>2023-12-21 15:00:55 -0500
commit619a9539ee378e635ba3a26300dff746a9ff4ba2 (patch)
tree4280bb426067ffac6f13db8d007d421aecf94a26 /gcc/tree-vect-loop-manip.cc
parent9a65c8ee659042babdb05ef15fea9910fa8d6e62 (diff)
downloadgcc-619a9539ee378e635ba3a26300dff746a9ff4ba2.zip
gcc-619a9539ee378e635ba3a26300dff746a9ff4ba2.tar.gz
gcc-619a9539ee378e635ba3a26300dff746a9ff4ba2.tar.bz2
c++: fix -Wparentheses for bool-like class types
Since r14-4977-g0f2e2080685e75 we now issue a -Wparentheses warning for extern std::vector<bool> v; bool b = v[0] = true; // warning: suggest parentheses around assignment used as truth value [-Wparentheses] I intended for that commit to just allow the existing diagnostics to happen in a template context as well, but the refactoring of is_assignment_op_expr_p caused us for this -Wparentheses warning from convert_for_assignment to now consider user-defined operator= expressions instead of just built-in operator=. And since std::vector<bool> is really a bitset, whose operator[] returns a class type with such a user-defined operator= (taking bool), we now warn here when we didn't use to. That we now accept user-defined operator= expressions is generally good, but arguably "boolish" class types should be treated like ordinary bool as far as the warning is concerned. To that end this patch suppresses the warning for such types, specifically when the class type can be implicitly converted to and assigned from bool. This criterion captures the std::vector<bool>::reference of libstdc++ at least. gcc/cp/ChangeLog: * cp-tree.h (maybe_warn_unparenthesized_assignment): Add 'nested_p' bool parameter. * semantics.cc (boolish_class_type_p_cache): Define. (boolish_class_type_p): Define. (maybe_warn_unparenthesized_assignment): Add 'nested_p' bool parameter. Suppress the warning for nested assignments to bool and bool-like class types. (maybe_convert_cond): Pass nested_p=false to maybe_warn_unparenthesized_assignment. * typeck.cc (convert_for_assignment): Pass nested_p=true to maybe_warn_unparenthesized_assignment. Remove now redundant check for 'rhs' having bool type. gcc/testsuite/ChangeLog: * g++.dg/warn/Wparentheses-34.C: New test.
Diffstat (limited to 'gcc/tree-vect-loop-manip.cc')
0 files changed, 0 insertions, 0 deletions