This is an obvious fix for this small regression. Basically after
r15-328-g5726de79e2154a,
there is a call to tree_expr_nonnegative_warnv_p where the type of the expression is now
error_mark_node. Though there was only a check if the expression was error_mark_node.
Bootstrapped and tested on x86_64-linux-gnu.
PR c/118948
gcc/ChangeLog:
* fold-const.cc (tree_expr_nonnegative_warnv_p): Use
error_operand_p instead of checking for error_mark_node directly.
gcc/testsuite/ChangeLog:
* gcc.dg/pr118948-1.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
tree_expr_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
{
enum tree_code code;
- if (t == error_mark_node)
+ if (error_operand_p (t))
return false;
code = TREE_CODE (t);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+/* PR c/118948 */
+
+/* Used to ICE in tree_expr_nonnegative_p after an error. */
+
+void f(void) {
+ int i; /* { dg-note "previous" } */
+ for (i = 0; i < 2; i++) ;
+ float i; /* { dg-error "conflicting types for" } */
+}