aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2004-07-09 23:20:36 +0000
committerRichard Henderson <rth@gcc.gnu.org>2004-07-09 16:20:36 -0700
commit8a2cee381065db182be6e18124193cc348b6b937 (patch)
tree7f15378fb80418b7903e8b6ed86c8514f95c236b /gcc
parent5806d4fd849871d77fdc9b5f6a1ef05d42039a52 (diff)
downloadgcc-8a2cee381065db182be6e18124193cc348b6b937.zip
gcc-8a2cee381065db182be6e18124193cc348b6b937.tar.gz
gcc-8a2cee381065db182be6e18124193cc348b6b937.tar.bz2
c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes permissible for unary plus.
* c-typeck.c (build_unary_op): include VECTOR_TYPE in set of codes permissible for unary plus. From-SVN: r84417
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/c-typeck.c3
-rw-r--r--gcc/testsuite/gcc.dg/simd-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/simd-1b.c36
-rw-r--r--gcc/testsuite/gcc.dg/simd-2.c55
5 files changed, 100 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3c59958..4e04942 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -6,6 +6,11 @@
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.
(BT_FN_UINT): Rename from BT_FN_UNSIGNED.
(BT_FN_PTR_UINT): Rename from BT_FN_PTR_UNSIGNED.
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index ca2e6df..2c6df14 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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;
diff --git a/gcc/testsuite/gcc.dg/simd-1.c b/gcc/testsuite/gcc.dg/simd-1.c
index 43e63e4..e36c5bee 100644
--- a/gcc/testsuite/gcc.dg/simd-1.c
+++ b/gcc/testsuite/gcc.dg/simd-1.c
@@ -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
index 0000000..d40fb04
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/simd-1b.c
@@ -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
index 0000000..20d4a07
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/simd-2.c
@@ -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" } */
+}