Bootstrapped and regression tested on x86_64.


    c: fix checking ICE on pointer to a VLA of a tagged type [PR126284]
    
    Remove the check for complete types in top_array_vla_p because
    it is incorrect and we may end up encountering an array with
    incomplete element type in c_verify_type.  This can happen by
    replacing structures or unions with their incomplete version when
    constructing the canonical type.
    
            PR c/126284
    
    gcc/c/ChangeLog:
            * c-typeck.cc (top_array_vla_p): Remove check.
    
    gcc/testsuite/ChangeLog:
            * gcc.dg/pr126284.c: New test.

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 5199a352ecc..ed234f075ca 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -4120,8 +4120,6 @@ top_array_vla_p (const_tree type)
 {
   if (TREE_CODE (type) != ARRAY_TYPE)
     return false;
-  if (!COMPLETE_TYPE_P (type))
-    return false;
 
   tree d = TYPE_DOMAIN (type);
 
diff --git a/gcc/testsuite/gcc.dg/pr126284.c b/gcc/testsuite/gcc.dg/pr126284.c
new file mode 100644
index 00000000000..b2a78539247
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr126284.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu23" } */
+
+struct S { int x; };
+void f (int n) { struct { struct S (*p)[n]; } s; }
+

Reply via email to