https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97860
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- The problem is that in the C FE TYPE_MAX_VALUE (TYPE_DOMAIN (type)) isn't set for the [0] types (yet they are complete), while the middle-end expects for them to have TYPE_MAX_VALUE of -1 or so, so array_type_nelts returns error_mark_node. We could do: /* array_type_nelts assumes the middle-end TYPE_DOMAINs, while GNU [0] array in the FE don't have TYPE_MAX_VALUE of the domain set, yet they are complete types with no elements. */ if (nelts == error_mark_node && TYPE_DOMAIN (type) && !TYPE_MAX_VALUE (TYPE_DOMAIN (type)) && COMPLETE_P (type) && integer_zerop (TYPE_SIZE (type))) continue; but then it doesn't make sense to queue up error_mark_nodes in the attributes when we ICE on them later, so perhaps better: 2020-11-18 Jakub Jelinek <ja...@redhat.com> PR c/97860 * c-decl.c (get_parm_array_spec): Don't chain error_mark_node as VLA bounds. * gcc.dg/pr97860.c: New test. --- gcc/c/c-decl.c.jj 2020-11-11 01:46:03.245697697 +0100 +++ gcc/c/c-decl.c 2020-11-18 15:11:14.613565216 +0100 @@ -5775,7 +5775,7 @@ get_parm_array_spec (const struct c_parm type = TREE_TYPE (type)) { tree nelts = array_type_nelts (type); - if (TREE_CODE (nelts) != INTEGER_CST) + if (TREE_CODE (nelts) != INTEGER_CST && nelts != error_mark_node) { /* Each variable VLA bound is represented by the dollar sign. */ --- gcc/testsuite/gcc.dg/pr97860.c.jj 2020-11-18 15:15:08.858931877 +0100 +++ gcc/testsuite/gcc.dg/pr97860.c 2020-11-18 15:14:50.751135430 +0100 @@ -0,0 +1,11 @@ +/* PR c/97860 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void +foo (int n) +{ + typedef int T[0]; + typedef T V[n]; + void bar (V); +}