aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2006-12-01 21:35:25 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2006-12-01 21:35:25 +0000
commit01c15146e42cb102382bb126dd96cc143c56a575 (patch)
tree3e50492fa180f9146d98cd3dc30d88e9263c3edf
parentd8e1d61976e33667ed0d9f8ae6f9619076ecad8a (diff)
downloadgcc-01c15146e42cb102382bb126dd96cc143c56a575.zip
gcc-01c15146e42cb102382bb126dd96cc143c56a575.tar.gz
gcc-01c15146e42cb102382bb126dd96cc143c56a575.tar.bz2
re PR c++/30022 (ICE on vector operand in division)
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: r119416
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/typeck.c14
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/g++.dg/ext/vector5.C8
4 files changed, 26 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index edcb388..1ecb96d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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-12-01 Ryan Mansfield <rmansfield@qnx.com>
PR c++/29066
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c5c9f38..1acd1ff 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -262,7 +262,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
@@ -3093,17 +3093,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 (OPT_Wdiv_by_zero, "division by zero in %<%E / 0%>", op0);
else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1))
warning (OPT_Wdiv_by_zero, "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 (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 (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
+ if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
resultcode = RDIV_EXPR;
else
/* When dividing two signed integers, we have to promote to int.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 31f6ea6..df43234 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2006-12-01 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+ PR c++/30022
+ * g++.dg/ext/vector5.C: New test.
+
PR c++/30021
* g++.dg/other/main1.C: New test.
diff --git a/gcc/testsuite/g++.dg/ext/vector5.C b/gcc/testsuite/g++.dg/ext/vector5.C
new file mode 100644
index 0000000..e5304bc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/vector5.C
@@ -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" }
+}