[gcc r17-3300] c: fix checking ICE on pointer to a VLA of a tagged type [PR126284]

Martin Uecker via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:736361789c1309e3aff154210c07653f06a769d9

commit r17-3300-g736361789c1309e3aff154210c07653f06a769d9
Author: Martin Uecker <[email protected]>
Date:   Sat Jul 18 23:07:31 2026 +0200

    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 not correct 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:
---
 gcc/c/c-typeck.cc               | 2 --
 gcc/testsuite/gcc.dg/pr126284.c | 6 ++++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 5199a352ecc9..ed234f075ca8 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 000000000000..b2a785392470
--- /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; }
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.