]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold: Change comparison of error_mark_node to use error_operand_p in tree_expr_nonneg...
authorAndrew Pinski <quic_apinski@quicinc.com>
Thu, 3 Jul 2025 18:58:50 +0000 (11:58 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Fri, 4 Jul 2025 15:28:31 +0000 (08:28 -0700)
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>
gcc/fold-const.cc
gcc/testsuite/gcc.dg/pr118948-1.c [new file with mode: 0644]

index 47492575d00610ead128ef8b20826914065490d1..8867540243b83cc32bd9a27acbdba2c049efe0f4 100644 (file)
@@ -15224,7 +15224,7 @@ bool
 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);
diff --git a/gcc/testsuite/gcc.dg/pr118948-1.c b/gcc/testsuite/gcc.dg/pr118948-1.c
new file mode 100644 (file)
index 0000000..2a46cf1
--- /dev/null
@@ -0,0 +1,12 @@
+/* { 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" } */
+}