https://gcc.gnu.org/g:e4fb1b435a65f505b0172b4f0213483c3a07adbf

commit r16-599-ge4fb1b435a65f505b0172b4f0213483c3a07adbf
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Mon May 12 18:58:32 2025 -0700

    verifier: Fix up PAREN_EXPR verification [PR118868]
    
    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>

Diff:
---
 gcc/testsuite/c-c++-common/pr118868-1.c |  9 +++++++++
 gcc/tree-cfg.cc                         | 12 +++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

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 000000000000..d0a9e77f7e57
--- /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 6a95b82ff404..928459a38b2a 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)

Reply via email to