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_apin...@quicinc.com>
---
 gcc/testsuite/c-c++-common/pr118868-1.c |  9 +++++++++
 gcc/tree-cfg.cc                         | 12 +++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/c-c++-common/pr118868-1.c

diff --git a/gcc/testsuite/c-c++-common/pr118868-1.c 
b/gcc/testsuite/c-c++-common/pr118868-1.c
new file mode 100644
index 00000000000..d0a9e77f7e5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr118868-1.c
@@ -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);
+}
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 712bda1f8ca..346ba4ab9f5 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -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)
-- 
2.43.0

Reply via email to