]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c/123716: Fix an unexpected error_mark_node ICE.
authorRoger Sayle <roger@nextmovesoftware.com>
Sun, 22 Feb 2026 22:32:05 +0000 (22:32 +0000)
committerRoger Sayle <roger@nextmovesoftware.com>
Sun, 22 Feb 2026 22:32:05 +0000 (22:32 +0000)
This patch resolves the P4 regression PR c/123716.

2026-02-22  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
PR c/123716
* tree.cc (tree_nop_conversion_p): Move sanity checks on
inner_type to here...
(tree_nop_conversion): ... from here.

gcc/testsuite/ChangeLog
PR c/123716
* gcc.dg/pr123716.c: New test case.

gcc/testsuite/gcc.dg/pr123716.c [new file with mode: 0644]
gcc/tree.cc

diff --git a/gcc/testsuite/gcc.dg/pr123716.c b/gcc/testsuite/gcc.dg/pr123716.c
new file mode 100644 (file)
index 0000000..0ac3436
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/123716 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+int f(unsigned s)
+{
+  int i;
+  for (i = 0; i < s; ++i);
+  unsigned i[1];  /* { dg-error "conflicting type" } */
+}
index 02f98f87003b7224f4d1e137b940730fe7db774b..d0e745e8d281afce27f8f3f0e25d5b13a5bdc0eb 100644 (file)
@@ -12333,6 +12333,9 @@ block_ultimate_origin (const_tree block)
 bool
 tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
 {
+  if (!inner_type || inner_type == error_mark_node)
+    return false;
+
   /* Do not strip casts into or out of differing address spaces.  */
   if (POINTER_TYPE_P (outer_type)
       && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
@@ -12382,8 +12385,6 @@ tree_nop_conversion (const_tree exp)
 
   outer_type = TREE_TYPE (exp);
   inner_type = TREE_TYPE (TREE_OPERAND (exp, 0));
-  if (!inner_type || inner_type == error_mark_node)
-    return false;
 
   return tree_nop_conversion_p (outer_type, inner_type);
 }