]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes permissible for...
authorJan Beulich <jbeulich@novell.com>
Fri, 9 Jul 2004 23:20:36 +0000 (23:20 +0000)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 9 Jul 2004 23:20:36 +0000 (16:20 -0700)
        * c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes
        permissible for unary plus.

From-SVN: r84417

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/gcc.dg/simd-1.c
gcc/testsuite/gcc.dg/simd-1b.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/simd-2.c [new file with mode: 0644]

index 3c59958f24d36e163eadf9acbd99f7728089f44f..4e049420392d5793b3a9355ff26325957f0b49e3 100644 (file)
@@ -4,6 +4,11 @@
        * config/ia64/ia64.c (ia64_function_arg): For a single element HFA,
        do return a parallel if hfa_mode == XFmode and mode == TImode.
 
+2004-07-09 Jan Beulich <jbeulich@novell.com>
+
+       * c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes
+       permissible for unary plus.
+
 2004-07-09 Jan Beulich <jbeulich@novell.com>
 
        * builtin-types.def (BT_UINT): Rename from BT_UNSIGNED.
index ca2e6df793e953560403bfe1c5e59d1de83205f4..2c6df142597163ca1341077e101349059c920292 100644 (file)
@@ -2303,7 +2303,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
         is enough to prevent anybody from looking inside for
         associativity, but won't generate any code.  */
       if (!(typecode == INTEGER_TYPE || typecode == REAL_TYPE
-           || typecode == COMPLEX_TYPE))
+           || typecode == COMPLEX_TYPE
+           || typecode == VECTOR_TYPE))
        {
          error ("wrong type argument to unary plus");
          return error_mark_node;
index 43e63e4a40e83e40bc65ac233aed1039e9c4b52d..e36c5beec5c927637db966a8a3faefc97082311a 100644 (file)
@@ -14,8 +14,8 @@ v2si c, d;
 v8hi e;
 uv4si f;
 
-int foo __attribute__((mode(DI)));
-int foo1 __attribute__((mode(SI)));
+long long foo;
+int foo1;
 short foo2 __attribute__((vector_size (8)));
 
 void
diff --git a/gcc/testsuite/gcc.dg/simd-1b.c b/gcc/testsuite/gcc.dg/simd-1b.c
new file mode 100644 (file)
index 0000000..d40fb04
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+/* Purpose: Program to test generic SIMD support.  */
+
+typedef int __attribute__((vector_size (16))) v4si;
+typedef int __attribute__((vector_size (8))) v2si;
+
+v4si a, b;
+v2si c, d;
+
+void
+hanneke ()
+{
+  /* Operators on compatible SIMD types.  */
+  a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
+  c &= d;
+  a |= b;
+  c ^= d;
+  a >>= b; /* { dg-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
+  c <<= d; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
+  a = +b;
+  c = ~d;
+
+  /* Operators on incompatible SIMD types.  */
+/*  a = b % c;  { dg*error "can't convert between vector values of different size" } */
+  a = b % c; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
+  d = c & b; /* { dg-error "can't convert between vector values of different size" } */
+  a = b | c; /* { dg-error "can't convert between vector values of different size" } */
+  d = c ^ b; /* { dg-error "can't convert between vector values of different size" } */
+/*  a = b >> c;  { dg*error "can't convert between vector values of different size" } */
+  a = b >> c; /* { dg-bogus "invalid operands to binary >>" "" { xfail *-*-* } } */
+/*  d = c << b;  { dg*error "can't convert between vector values of different size" } */
+  d = c << b; /* { dg-bogus "invalid operands to binary <<" "" { xfail *-*-* } } */
+}
diff --git a/gcc/testsuite/gcc.dg/simd-2.c b/gcc/testsuite/gcc.dg/simd-2.c
new file mode 100644 (file)
index 0000000..20d4a07
--- /dev/null
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+/* Origin: Aldy Hernandez <aldyh@redhat.com>.  */
+/* Purpose: Program to test generic SIMD support.  */
+
+typedef float __attribute__((vector_size(8))) v2sf;
+typedef float __attribute__((vector_size(16))) v4sf;
+typedef double __attribute__((vector_size(16))) v2df;
+
+v4sf a, b;
+v2sf c, d;
+v2df e;
+
+double foo;
+float foo1;
+v2sf foo2;
+
+void
+hanneke ()
+{
+  /* Assignment.  */
+  a = b;
+
+  /* Assignment of different types.  */
+  b = c; /* { dg-error "incompatible types in assignment" } */
+  d = a; /* { dg-error "incompatible types in assignment" } */
+
+  /* Casting between SIMDs of the same size.  */
+  e = (typeof (e)) a;
+
+  /* Assignment between scalar and SIMD of different size.  */
+  foo = a; /* { dg-error "incompatible types in assignment" } */
+
+  /* Casted assignment between scalar and SIMD of same size.  */
+  foo = (typeof (foo)) foo2; /* { dg-bogus "aggregate value used where a float was expected" "" { xfail *-*-* } } */
+
+  /* Casted assignment between scalar and SIMD of different size.  */
+/*  foo1 = (typeof (foo1)) foo2;  { dg*error "can't convert between vector values of different size" } */
+  foo1 = (typeof (foo1)) foo2; /* { dg-bogus "aggregate value used where a float was expected" "" { xfail *-*-* } } */
+
+  /* Operators on compatible SIMD types.  */
+  a += b + b;
+  a -= b;
+  a *= b;
+  a /= b;
+  a = +b;
+  c = -d;
+
+  /* Operators on incompatible SIMD types.  */
+  a = b + c; /* { dg-error "can't convert between vector values of different size" } */
+  a = b - c; /* { dg-error "can't convert between vector values of different size" } */
+  a = b * c; /* { dg-error "can't convert between vector values of different size" } */
+  a = b / c; /* { dg-error "can't convert between vector values of different size" } */
+}