]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
typeck.c (build_binary_op): Same.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 15 Jun 2005 10:35:19 +0000 (10:35 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Wed, 15 Jun 2005 10:35:19 +0000 (10:35 +0000)
* typeck.c (build_binary_op): Same.
* testsuite/g++.dg/conversion/simd3.C: New.

From-SVN: r100977

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/g++.dg/conversion/simd3.C [new file with mode: 0644]

index 8a24049ba1ce8a5a154bad8849e90d5db56b92fb..996664a19c1d774d25ef5978669b2e6746dd4673 100644 (file)
@@ -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
index 3581ea2749bec3c41aa10282e63094cf17a3495c..58ba0798aaeeeab8e4c080c31a2e1b8b71d86990 100644 (file)
@@ -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 (file)
index 0000000..f7b28d4
--- /dev/null
@@ -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;
+}