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>
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. */
= objc_build_message_expr (rec, args);
mexpr.original_code = ERROR_MARK;
mexpr.original_type = NULL;
+ mexpr.m_decimal = 0;
/* Now parse and process the remainder of the
initializer, starting with this message
expression as a primary-expression. */
set_c_expr_source_range (&ret, cast_loc, expr.get_finish ());
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
+ ret.m_decimal = 0;
return ret;
}
else
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
set_c_expr_source_range (&ret, start_loc, end_loc);
+ ret.m_decimal = 0;
return ret;
}
else
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
set_c_expr_source_range (&ret, start_loc, end_loc);
+ ret.m_decimal = 0;
return ret;
}
}
expr.value = build_compound_literal (start_loc, type, init.value, non_const,
alignas_align);
set_c_expr_source_range (&expr, init.src_range);
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
if (type != error_mark_node
set_c_expr_source_range (&expr, start, finish);
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
+ expr.m_decimal = 0;
break;
case CPP_OPEN_PAREN:
/* Function call. */
= c_build_function_call_vec (expr_loc, arg_loc, expr.value,
exprlist, origtypes);
set_c_expr_source_range (&expr, start, finish);
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) == INTEGER_CST
else
expr.original_type = DECL_BIT_FIELD_TYPE (field);
}
+ expr.m_decimal = 0;
break;
case CPP_DEREF:
/* Structure element reference. */
else
expr.original_type = DECL_BIT_FIELD_TYPE (field);
}
+ expr.m_decimal = 0;
break;
case CPP_PLUS_PLUS:
/* Postincrement. */
expr.value = build_compound_expr (loc, expr.value, next.value);
expr.original_code = COMPOUND_EXPR;
expr.original_type = next.original_type;
+ expr.m_decimal = 0;
}
return expr;
}
t_expr.original_code = ERROR_MARK;
t_expr.original_type = NULL;
set_c_expr_source_range (&t_expr, op_loc, op_loc);
+ t_expr.m_decimal = 0;
t_expr = convert_lvalue_to_rvalue (op_loc, t_expr,
true, false);
t = build_indirect_ref (op_loc, t_expr.value, RO_ARROW);
TRANSACTION_EXPR_RELAXED (ret.value) = 1;
SET_EXPR_LOCATION (ret.value, loc);
ret.original_code = TRANSACTION_EXPR;
+ ret.m_decimal = 0;
if (!parens.require_close (parser))
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
}
/* Set the value to error_mark_node whilst ensuring that src_range
- is initialized. */
+ and m_decimal are initialized. */
void set_error ()
{
value = error_mark_node;
src_range.m_start = UNKNOWN_LOCATION;
src_range.m_finish = UNKNOWN_LOCATION;
+ m_decimal = 0;
}
};
ret.value = error_mark_node;
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
+ ret.m_decimal = 0;
pop_maybe_used (false);
}
else
c_last_sizeof_loc = loc;
ret.original_code = SIZEOF_EXPR;
ret.original_type = NULL;
+ ret.m_decimal = 0;
if (C_TYPE_VARIABLE_SIZE (TREE_TYPE (folded_expr)))
{
/* sizeof is evaluated when given a vla (C99 6.5.3.4p2). */
c_last_sizeof_loc = loc;
ret.original_code = SIZEOF_EXPR;
ret.original_type = NULL;
+ ret.m_decimal = 0;
if (type == error_mark_node)
{
ret.value = error_mark_node;
result.original_code = code;
result.original_type = NULL;
+ result.m_decimal = 0;
if (reject_gcc_builtin (arg.value))
{
arg1.value, arg2.value, true);
result.original_code = code;
result.original_type = NULL;
+ result.m_decimal = 0;
if (TREE_CODE (result.value) == ERROR_MARK)
{
expr.value = inside_init;
expr.original_code = (strict_string ? STRING_CST : ERROR_MARK);
expr.original_type = NULL;
+ expr.m_decimal = 0;
maybe_warn_string_init (init_loc, type, expr);
if (TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)))
ret.value = NULL_TREE;
ret.original_code = ERROR_MARK;
ret.original_type = NULL;
+ ret.m_decimal = 0;
if (implicit == 0)
{
exprlist.address ());
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
+ expr.m_decimal = 0;
}
}
return expr;
finish = c_parser_tokens_buf (parser, 0)->location;
expr.value = build_array_ref (op_loc, expr.value, idx);
set_c_expr_source_range (&expr, start, finish);
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
expr.value = build_call_array_loc
(expr_loc, TREE_TYPE (TREE_TYPE (expr.value)),
expr.value, exprlist.length (), exprlist.address ());
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
expr.original_type = NULL;
break;
expr.value = build_component_ref (op_loc, expr.value, ident,
comp_loc, UNKNOWN_LOCATION);
set_c_expr_source_range (&expr, start, finish);
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
expr.original_type = NULL;
ident, comp_loc,
expr.get_location ());
set_c_expr_source_range (&expr, start, finish);
+ expr.m_decimal = 0;
expr.original_code = ERROR_MARK;
if (TREE_CODE (expr.value) != COMPONENT_REF)
expr.original_type = NULL;
--- /dev/null
+/* { dg-require-effective-target int128 }
+ { dg-options "-Wno-pedantic" } */
+
+void foo0_u16_0() {
+ (__int128)(18302628885633695743 << 4) ^ 0; /* { dg-warning "integer constant is so large that it is unsigned" } */
+}