diff options
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/conversion/simd3.C | 15 |
3 files changed, 27 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a24049..996664a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-06-15 Aldy Hernandez <aldyh@redhat.com> + + * typeck.c (build_binary_op): Same. + * testsuite/g++.dg/conversion/simd3.C: New. + 2005-06-15 Nathan Sidwell <nathan@codesourcery.com> PR c++/20678 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3581ea2..58ba0798 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -3181,8 +3181,13 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, /* Vector arithmetic is only allowed when both sides are vectors. */ if (code0 == VECTOR_TYPE && code1 == VECTOR_TYPE) { - if (!tree_int_cst_equal (TYPE_SIZE (type0), TYPE_SIZE (type1))) - error ("can't convert between vector values of different size"); + if (!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; + } arithmetic_types_p = 1; } } diff --git a/gcc/testsuite/g++.dg/conversion/simd3.C b/gcc/testsuite/g++.dg/conversion/simd3.C new file mode 100644 index 0000000..f7b28d4 --- /dev/null +++ b/gcc/testsuite/g++.dg/conversion/simd3.C @@ -0,0 +1,15 @@ +/* { 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; +} |