]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
verifier: Fix up PAREN_EXPR verification [PR118868]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 13 May 2025 01:58:32 +0000 (18:58 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Tue, 13 May 2025 15:29:12 +0000 (08:29 -0700)
The verification added in r12-1608-g2f1686ff70b25f, was incorrect
for PAREN_EXPR, pointer types should be valid for PAREN_EXPR.
Also for PAREN_EXPR, aggregate types don't make sense (currently
they ICE much earlier in the gimplifier rather than error message) so
we should disallow them here too.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/118868

gcc/ChangeLog:

* tree-cfg.cc (verify_gimple_assign_unary): Allow pointers
but disallow aggregate types for PAREN_EXPR.

gcc/testsuite/ChangeLog:

* c-c++-common/pr118868-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/testsuite/c-c++-common/pr118868-1.c [new file with mode: 0644]
gcc/tree-cfg.cc

diff --git a/gcc/testsuite/c-c++-common/pr118868-1.c b/gcc/testsuite/c-c++-common/pr118868-1.c
new file mode 100644 (file)
index 0000000..d0a9e77
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+/* PR middle-end/118868 */
+
+/* __builtin_assoc_barrier should work on pointers without any ICE */
+void *f(void *a)
+{
+  return __builtin_assoc_barrier(a);
+}
index 6a95b82ff404aea7e5de542879b9fff0d1958412..928459a38b2a7c5e569c5ce768bf3b6470eda7b1 100644 (file)
@@ -3870,7 +3870,6 @@ verify_gimple_assign_unary (gassign *stmt)
     case NEGATE_EXPR:
     case ABS_EXPR:
     case BIT_NOT_EXPR:
-    case PAREN_EXPR:
     case CONJ_EXPR:
       /* Disallow pointer and offset types for many of the unary gimple. */
       if (POINTER_TYPE_P (lhs_type)
@@ -3883,6 +3882,17 @@ verify_gimple_assign_unary (gassign *stmt)
        }
       break;
 
+    case PAREN_EXPR:
+      /* Disallow non arthmetic types on PAREN_EXPR. */
+      if (AGGREGATE_TYPE_P (lhs_type))
+       {
+         error ("invalid types for %qs", code_name);
+         debug_generic_expr (lhs_type);
+         debug_generic_expr (rhs1_type);
+         return true;
+       }
+      break;
+
     case ABSU_EXPR:
       if (!ANY_INTEGRAL_TYPE_P (lhs_type)
          || !TYPE_UNSIGNED (lhs_type)