There is an assumption in many places in c-typeck.cc that GNU vectors sizes are
always known at compile time.  SVE vectors now piggy-back on GNU vector code
so this patch changes one of the places where there is an assumption of vectors
being fixed-length to being variable width.

gcc/ChangeLog:

        * c/c-typeck.cc (process_init_element): Fix condition to include
        sizeless types.
---
 gcc/c/c-typeck.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 6673cbf7294..94959f7b8ad 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -11969,8 +11969,9 @@ retry:
          tree elttype = TYPE_MAIN_VARIANT (TREE_TYPE (constructor_type));
 
         /* Do a basic check of initializer size.  Note that vectors
-           always have a fixed size derived from their type.  */
-         if (tree_int_cst_lt (constructor_max_index, constructor_index))
+           may not always have a fixed size derived from their type.  */
+         if (known_lt (tree_to_poly_uint64 (constructor_max_index),
+                       tree_to_poly_uint64 (constructor_index)))
            {
              pedwarn_init (loc, 0,
                            "excess elements in vector initializer");
-- 
2.25.1

Reply via email to