diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-04 08:07:09 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-04 08:07:09 +0000 |
commit | 39cc3e6db49658d78cf2f69b62d8307c6785149a (patch) | |
tree | 3cac5cc0fee67f928ce2528c8de83b7102ca5f10 /gcc | |
parent | 9338678e8a336a8fb58dbdd27f407cc467a90faa (diff) | |
download | gcc-39cc3e6db49658d78cf2f69b62d8307c6785149a.tar.gz |
PR c/25559
* c-common.c (handle_vector_size_attribute): Reject zero vector size
as well as sizes not multiple of component size.
* gcc.dg/pr25559.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109316 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-common.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr25559.c | 10 |
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4f8b626fe2..8e2759752a0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2006-01-04 Jakub Jelinek <jakub@redhat.com> + PR c/25559 + * c-common.c (handle_vector_size_attribute): Reject zero vector size + as well as sizes not multiple of component size. + PR debug/25562 * function.c (instantiate_expr): New function. (instantiate_decls_1, instantiate_decls): If DECL_HAS_VALUE_EXPR_P, diff --git a/gcc/c-common.c b/gcc/c-common.c index b2523459458..76e90962f9b 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5199,6 +5199,18 @@ handle_vector_size_attribute (tree *node, tree name, tree args, return NULL_TREE; } + if (vecsize % tree_low_cst (TYPE_SIZE_UNIT (type), 1)) + { + error ("vector size not an integral multiple of component size"); + return NULL; + } + + if (vecsize == 0) + { + error ("zero vector size"); + return NULL; + } + /* Calculate how many units fit in the vector. */ nunits = vecsize / tree_low_cst (TYPE_SIZE_UNIT (type), 1); if (nunits & (nunits - 1)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e02c3c7a510..23350e1ca55 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-01-04 Jakub Jelinek <jakub@redhat.com> + + PR c/25559 + * gcc.dg/pr25559.c: New test. + 2006-01-03 Mark Mitchell <mark@codesourcery.com> PR c++/25492 diff --git a/gcc/testsuite/gcc.dg/pr25559.c b/gcc/testsuite/gcc.dg/pr25559.c new file mode 100644 index 00000000000..7879a1558b6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr25559.c @@ -0,0 +1,10 @@ +/* PR c/25559 */ +/* { dg-do compile } */ + +#define vs(n) __attribute__((vector_size (n))) +int vs (-1) a; /* { dg-warning "attribute ignored" } */ +int vs (0) b; /* { dg-error "zero vector size" } */ +int vs (1) c; /* { dg-error "multiple of component size" } */ +int vs (sizeof (int) / 2) d; /* { dg-error "multiple of component size" } */ +int vs (sizeof (int)) e; +int vs (sizeof (int) * 2) f; |