From: Christophe Lyon Date: Tue, 17 Mar 2020 09:26:08 +0000 (+0000) Subject: c: ignore initializers for elements of variable-size types [PR93577] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fd857de80705be937d9780dbd394d006151713fe;p=gcc.git c: ignore initializers for elements of variable-size types [PR93577] 2020-03-17 Christophe Lyon gcc/ * c-typeck.c (process_init_element): Handle constructor_type with type size represented by POLY_INT_CST. gcc/testsuite/ * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c: Remove superfluous dg-error. * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Likewise. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f8105ccc67d..06c7db0245a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2020-03-17 Christophe Lyon + + * c-typeck.c (process_init_element): Handle constructor_type with + type size represented by POLY_INT_CST. + 2020-03-17 Jakub Jelinek PR tree-optimization/94187 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index d8025de1996..490d8fc5f4a 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -9968,7 +9968,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit, /* Ignore elements of an initializer for a variable-size type. Those are diagnosed in digest_init. */ if (COMPLETE_TYPE_P (constructor_type) - && TREE_CODE (TYPE_SIZE (constructor_type)) != INTEGER_CST) + && !poly_int_tree_p (TYPE_SIZE (constructor_type))) return; if (!implicit && warn_designated_init && !was_designated diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 879a67d88ef..aaf973a206c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-03-17 Christophe Lyon + + * gcc.target/aarch64/sve/acle/general-c/sizeless-1.c: Remove + superfluous dg-error. + * gcc.target/aarch64/sve/acle/general-c/sizeless-2.c: Likewise. + 2020-03-17 Jakub Jelinek PR middle-end/94189 diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c index 045963d5c76..7fc51e7ad18 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-1.c @@ -83,7 +83,6 @@ statements (int n) svint8_t array[2]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ svint8_t zero_length_array[0]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ svint8_t empty_init_array[] = {}; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ - /* { dg-error {empty scalar initializer} "" { target *-*-* } .-1 } */ typedef svint8_t vla_type[n]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ /* Assignment. */ diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c index c7282faba46..3af36de9994 100644 --- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c +++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general-c/sizeless-2.c @@ -83,7 +83,6 @@ statements (int n) svint8_t array[2]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ svint8_t zero_length_array[0]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ svint8_t empty_init_array[] = {}; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ - /* { dg-error {empty scalar initializer} "" { target *-*-* } .-1 } */ typedef svint8_t vla_type[n]; /* { dg-error {array elements cannot have SVE type 'svint8_t'} } */ /* Assignment. */