re PR c/25559 (Internal compiler error when specifying vector_size(2) of int)
authorJakub Jelinek <jakub@redhat.com>
Wed, 4 Jan 2006 08:07:09 +0000 (09:07 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 4 Jan 2006 08:07:09 +0000 (09:07 +0100)
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.

From-SVN: r109316

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr25559.c [new file with mode: 0644]

index c4f8b62..8e27597 100644 (file)
@@ -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,
index b252345..76e9096 100644 (file)
@@ -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))
index e02c3c7..23350e1 100644 (file)
@@ -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 (file)
index 0000000..7879a15
--- /dev/null
@@ -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;