* c-common.h (same_scalar_type_ignoring_signedness): Protoize.
* c-common.c (same_scalar_type_ignoring_signedness): New.
* c-typeck.c (build_binary_op): Check compatability of vector
types. Move error report after switch.
Do not clobber code[01] on *_DIV_EXPR case.
* testsuite/gcc.dg/simd-1.c: Update error messages.
* testsuite/gcc.dg/simd-1b.c: Re-enable tests. Update error
messages.
* testsuite/gcc.dg/simd-2.c: Update error messages.
* testsuite/gcc.dg/simd-4.c: New.
From-SVN: r100976
+2005-06-15 Aldy Hernandez <aldyh@redhat.com>
+
+ * c-common.h (same_scalar_type_ignoring_signedness): Protoize.
+
+ * c-common.c (same_scalar_type_ignoring_signedness): New.
+
+ * c-typeck.c (build_binary_op): Check compatability of vector
+ types. Move error report after switch.
+ Do not clobber code[01] on *_DIV_EXPR case.
+
+ * testsuite/gcc.dg/simd-1.c: Update error messages.
+ * testsuite/gcc.dg/simd-1b.c: Re-enable tests. Update error
+ messages.
+ * testsuite/gcc.dg/simd-2.c: Update error messages.
+ * testsuite/gcc.dg/simd-4.c: New.
+
2005-06-15 Bernd Schmidt <bernd.schmidt@analog.com>
* Makefile.in (local-alloc.o): Depend on $(GGC_H) and reload.h.
}
}
+/* Ignoring their sign, return true if two scalar types are the same. */
+bool
+same_scalar_type_ignoring_signedness (tree t1, tree t2)
+{
+ enum tree_code c1 = TREE_CODE (t1), c2 = TREE_CODE (t2);
+
+ gcc_assert ((c1 == INTEGER_TYPE || c1 == REAL_TYPE)
+ && (c2 == INTEGER_TYPE || c2 == REAL_TYPE));
+
+ /* Equality works here because c_common_signed_type uses
+ TYPE_MAIN_VARIANT. */
+ return lang_hooks.types.signed_type (t1)
+ == lang_hooks.types.signed_type (t2);
+}
+
#include "gt-c-common.h"
extern void overflow_warning (tree);
extern void unsigned_conversion_warning (tree, tree);
extern bool c_determine_visibility (tree);
+extern bool same_scalar_type_ignoring_signedness (tree, tree);
#define c_sizeof(T) c_sizeof_or_alignof_type (T, true, 1)
#define c_alignof(T) c_sizeof_or_alignof_type (T, false, 1)
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
{
+ enum tree_code tcode0 = code0, tcode1 = code1;
+
if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
- code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
+ tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
- code1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
+ tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
- if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
+ if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
resultcode = RDIV_EXPR;
else
/* Although it would be tempting to shorten always here, that
if (code0 == ERROR_MARK || code1 == ERROR_MARK)
return error_mark_node;
+ if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE
+ && (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))
+ || !same_scalar_type_ignoring_signedness (TREE_TYPE (type0),
+ TREE_TYPE (type1))))
+ {
+ binary_op_error (code);
+ return error_mark_node;
+ }
+
if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE
|| code0 == VECTOR_TYPE)
&&
+2005-06-15 Aldy Hernandez <aldyh@redhat.com>
+
+ * gcc.dg/simd-1.c: Update error messages.
+ * gcc.dg/simd-1b.c: Re-enable tests. Update error messages.
+ * gcc.dg/simd-2.c: Update error messages.
+ * gcc.dg/simd-4.c: New.
+
2005-06-15 Nathan Sidwell <nathan@codesourcery.com>
PR c++/20678
a = -b;
/* 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" } */
+ a = b + c; /* { dg-error "invalid operands to binary +" } */
+ a = b - c; /* { dg-error "invalid operands to binary -" } */
+ a = b * c; /* { dg-error "invalid operands to binary *" } */
+ a = b / c; /* { dg-error "invalid operands to binary /" } */
}
hanneke ()
{
/* Operators on compatible SIMD types. */
- a %= b; /* { dg-bogus "invalid operands to binary %" "" { xfail *-*-* } } */
+ a %= b; /* { dg-error "invalid operands to binary %" } */
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; /* { dg-error "invalid operands to binary >>" } */
+ c <<= d; /* { dg-error "invalid operands to binary <<" } */
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 *-*-* } } */
+ a = b % c; /* { dg-error "invalid operands to binary" } */
+ a = b % c; /* { dg-error "invalid operands to binary" } */
+ d = c & b; /* { dg-error "invalid operands to binary" } */
+ a = b | c; /* { dg-error "invalid operands to binary" } */
+ d = c ^ b; /* { dg-error "invalid operands to binary" } */
+ a = b >> c; /* { dg-error "invalid operands to binary" } */
+ a = b >> c; /* { dg-error "invalid operands to binary" } */
+ d = c << b; /* { dg-error "invalid operands to binary" } */
+ d = c << b; /* { dg-error "invalid operands to binary" } */
}
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 *-*-* } } */
+ foo = (typeof (foo)) foo2; /* { dg-error "aggregate value used where a float was expected" } */
/* 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 *-*-* } } */
+ foo1 = (typeof (foo1)) foo2; /* { dg-error "aggregate value used where a float was expected" } */
/* Operators on compatible SIMD types. */
a += b + 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" } */
+ a = b + c; /* { dg-error "invalid operands to binary" } */
+ a = b - c; /* { dg-error "invalid operands to binary" } */
+ a = b * c; /* { dg-error "invalid operands to binary" } */
+ a = b / c; /* { dg-error "invalid operands to binary" } */
}
--- /dev/null
+/* { dg-do compile } */
+
+typedef int myint;
+
+float __attribute__((vector_size(16))) b;
+int __attribute__((vector_size(16))) d;
+myint __attribute__((vector_size(16))) d2;
+unsigned int __attribute__((vector_size(16))) e;
+
+void foo()
+{
+ b + d; /* { dg-error "invalid operands to binary" } */
+ d += e;
+ d2 += d;
+}