From: Aldy Hernandez Date: Wed, 15 Jun 2005 10:35:19 +0000 (+0000) Subject: typeck.c (build_binary_op): Same. X-Git-Tag: misc/cutover-cvs2svn~2402 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6d7e7d8c0a2d025da90575eb488603ca0d22ec7;p=thirdparty%2Fgcc.git typeck.c (build_binary_op): Same. * typeck.c (build_binary_op): Same. * testsuite/g++.dg/conversion/simd3.C: New. From-SVN: r100977 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8a24049ba1ce..996664a19c1d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2005-06-15 Aldy Hernandez + + * typeck.c (build_binary_op): Same. + * testsuite/g++.dg/conversion/simd3.C: New. + 2005-06-15 Nathan Sidwell PR c++/20678 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3581ea2749be..58ba0798aaee 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 000000000000..f7b28d452298 --- /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; +}