diff options
author | David Malcolm <dmalcolm@redhat.com> | 2022-09-22 08:35:26 -0400 |
---|---|---|
committer | David Malcolm <dmalcolm@redhat.com> | 2022-09-22 08:35:26 -0400 |
commit | 86254629b636db579616befde49022f098af8148 (patch) | |
tree | a4b54ac73c403e0bcacf3e7d9bf9c232da7e005d /gcc/c-family | |
parent | 9baee6181b4e427e0b5ba417e51424c15858dce7 (diff) | |
download | gcc-86254629b636db579616befde49022f098af8148.zip gcc-86254629b636db579616befde49022f098af8148.tar.gz gcc-86254629b636db579616befde49022f098af8148.tar.bz2 |
c: fix uninitialized c_expr::m_decimal [PR106830]
I added c_expr::m_decimal in r13-2386-gbedfca647a9e9c1a as part of the
implementation of -Wxor-used-as-pow, but I missed various places where
the field needed to be initialized.
Fixed thusly.
gcc/c-family/ChangeLog:
PR c/106830
* c-warn.cc (check_for_xor_used_as_pow): Don't try checking
values that don't fit in uhwi.
gcc/c/ChangeLog:
PR c/106830
* c-parser.cc (c_parser_initelt): Initialize m_decimal.
(c_parser_cast_expression): Likewise.
(c_parser_alignof_expression): Likewise.
(c_parser_postfix_expression_after_paren_type): Likewise.
(c_parser_postfix_expression_after_primary): Likewise.
(c_parser_expression): Likewise.
(c_parser_omp_variable_list): Likewise.
(c_parser_transaction_expression): Likewise.
* c-tree.h (c_expr::set_error): Likewise.
* c-typeck.cc (c_expr_sizeof_expr): Likewise.
(parser_build_unary_op): Likewise.
(parser_build_binary_op): Likewise.
(digest_init): Likewise.
(pop_init_level): Likewise.
* gimple-parser.cc (c_parser_gimple_call_internal): Likewise.
gcc/testsuite/ChangeLog:
PR c/106830
* gcc.dg/Wxor-used-as-pow-pr106830.c: New test.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/c-warn.cc | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc index ed79cc3..6742f44 100644 --- a/gcc/c-family/c-warn.cc +++ b/gcc/c-family/c-warn.cc @@ -3809,12 +3809,9 @@ check_for_xor_used_as_pow (location_t lhs_loc, tree lhs_val, location_t operator_loc, tree rhs_val) { - /* Only complain if both args are non-negative integer constants. */ - if (!(TREE_CODE (lhs_val) == INTEGER_CST - && tree_int_cst_sgn (lhs_val) >= 0)) - return; - if (!(TREE_CODE (rhs_val) == INTEGER_CST - && tree_int_cst_sgn (rhs_val) >= 0)) + /* Only complain if both args are non-negative integer constants that fit + in uhwi. */ + if (!tree_fits_uhwi_p (lhs_val) || !tree_fits_uhwi_p (rhs_val)) return; /* Only complain if the LHS is 2 or 10. */ |