]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/30022 (ICE on vector operand in division)
authorVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 1 Dec 2006 22:32:00 +0000 (22:32 +0000)
committerVolker Reichelt <reichelt@gcc.gnu.org>
Fri, 1 Dec 2006 22:32:00 +0000 (22:32 +0000)
PR c++/30022
* typeck.c (type_after_usual_arithmetic_conversions):
Fix assertion for vector types.
(build_binary_op): Use temporary for inner type of vector types.

* g++.dg/ext/vector5.C: New test.

From-SVN: r119420

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

index eb53b785c34a29fc93b2ff2ba5d81bf25c1d094b..25363ad048d458c95bfafceebef92798b7594cec 100644 (file)
@@ -1,3 +1,10 @@
+2006-12-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/30022
+       * typeck.c (type_after_usual_arithmetic_conversions):
+       Fix assertion for vector types.
+       (build_binary_op): Use temporary for inner type of vector types.
+
 2006-10-11  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR c++/28302
index 38e542b4964cc57549bef1846fe434fe8a45fcc7..cc3d57bae2aa59603f1036863e5631bff239e9d7 100644 (file)
@@ -274,7 +274,7 @@ type_after_usual_arithmetic_conversions (tree t1, tree t2)
              || TREE_CODE (t1) == ENUMERAL_TYPE);
   gcc_assert (ARITHMETIC_TYPE_P (t2) 
              || TREE_CODE (t2) == COMPLEX_TYPE
-             || TREE_CODE (t1) == VECTOR_TYPE
+             || TREE_CODE (t2) == VECTOR_TYPE
              || TREE_CODE (t2) == ENUMERAL_TYPE);
 
   /* In what follows, we slightly generalize the rules given in [expr] so
@@ -2901,17 +2901,19 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
          && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
              || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
        {
+         enum tree_code tcode0 = code0, tcode1 = code1;
+
          if (TREE_CODE (op1) == INTEGER_CST && integer_zerop (op1))
            warning ("division by zero in %<%E / 0%>", op0);
          else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1))
            warning ("division by zero in %<%E / 0.%>", op0);
-             
-         if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
-           code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
-         if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
-           code1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
 
-         if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
+         if (tcode0 == COMPLEX_TYPE || tcode0 == VECTOR_TYPE)
+           tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
+         if (tcode1 == COMPLEX_TYPE || tcode1 == VECTOR_TYPE)
+           tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
+
+         if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
            resultcode = RDIV_EXPR;
          else
            /* When dividing two signed integers, we have to promote to int.
index 4f891090b112aa2ffaf4e083db051b3e404c8144..d18693da0703187a7d71b63963a61eb896be8345 100644 (file)
@@ -1,6 +1,11 @@
+2006-12-01  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/30022
+       * g++.dg/ext/vector5.C: New test.
+
 2006-11-02  Zdenek Dvorak <dvorakz@suse.cz>
 
-       * gcc++.dg/tree-ssa/pr27891.c: New test.
+       * g++.dg/tree-ssa/pr27891.c: New test.
 
 2006-11-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
diff --git a/gcc/testsuite/g++.dg/ext/vector5.C b/gcc/testsuite/g++.dg/ext/vector5.C
new file mode 100644 (file)
index 0000000..e5304bc
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/30022
+// { dg-do compile }
+
+void foo()
+{
+  int __attribute__((vector_size(8))) v;
+  v = 1/v;  // { dg-error "invalid operands of types" }
+}