This rejects a number of vector components that does not fit an 'int' which is an internal limitation of RTVEC.
This regresses gcc.dg/attr-vector_size.c which checks for much larger supported vectors. Not sure what to do about this - I'll also note the RTVEC limitation is a host specific limitation (unless we change this 'int' to int32_t). Bootstrapped and tested on x86_64-unknown-linux-gnu with the above mentioned regression. Any comments? Thanks, Richard. 2021-05-12 Richard Biener <rguent...@suse.de> PR c/100547 gcc/c-family/ * c-attribs.c (type_valid_for_vector_size): Reject too large nunits. * gcc.dg/pr100547.c: New testcase. --- gcc/c-family/c-attribs.c | 10 ++++++++++ gcc/testsuite/gcc.dg/pr100547.c | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pr100547.c diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c index c1f652d1dc9..60bcfa22df1 100644 --- a/gcc/c-family/c-attribs.c +++ b/gcc/c-family/c-attribs.c @@ -4252,6 +4252,16 @@ type_valid_for_vector_size (tree type, tree atname, tree args, return NULL_TREE; } + if (nunits >= (unsigned HOST_WIDE_INT)INT_MAX) + { + if (error_p) + error ("number of components of the vector exceeds %d", INT_MAX); + else + warning (OPT_Wattributes, + "number of components of the vector exceeds %d", INT_MAX); + return NULL_TREE; + } + if (ptrnunits) *ptrnunits = nunits; diff --git a/gcc/testsuite/gcc.dg/pr100547.c b/gcc/testsuite/gcc.dg/pr100547.c new file mode 100644 index 00000000000..92f34bf974f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr100547.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O -g" } */ + +typedef int __attribute__((vector_size( + ((((((((((((((((((((((((((((((8 * sizeof(short)) * sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)) * + sizeof(short)))) V; /* { dg-error "number of components" } */ +void k() { V w = { 0 }; } -- 2.26.2