This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR C++/28302, ICE with bitwise NOT and vectors (and C++)
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 15 Aug 2006 09:09:54 -0700
- Subject: [PATCH] Fix PR C++/28302, ICE with bitwise NOT and vectors (and C++)
The problem here is that we try to call perform_integral_promotions on a
vector type which causes a crash. The way to fix this is to avoid the
call for non integral types. We have already diagnostic invalid
operands to the expression by the time we get to calling
perform_integral_promotions so avoiding the call is the best way.
Also UNARY_MINUS_EXPR and PLUS_EXPR are handled this way.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
:ADDPATCH C++:
Thanks,
Andrew Pinski
cp/ChangeLog:
* typeck.c (build_unary_op <case BIT_NOT_EXPR:>): Don't call
perform_integral_promotions for non integral types.
testsuite/ChangeLog:
* g++.dg/ext/vector3.C: New test.
Index: testsuite/g++.dg/ext/vector3.C
===================================================================
--- testsuite/g++.dg/ext/vector3.C (revision 0)
+++ testsuite/g++.dg/ext/vector3.C (revision 0)
@@ -0,0 +1,7 @@
+int __attribute__((vector_size(8))) x;
+
+void foo()
+{
+ ~x;
+}
+
Index: cp/typeck.c
===================================================================
--- cp/typeck.c (revision 116148)
+++ cp/typeck.c (working copy)
@@ -3996,7 +3996,7 @@ build_unary_op (enum tree_code code, tre
else if (!(arg = build_expr_type_conversion (WANT_INT | WANT_ENUM,
arg, true)))
errstring = "wrong type argument to bit-complement";
- else if (!noconvert)
+ else if (!noconvert && CP_INTEGRAL_TYPE_P (TREE_TYPE (arg)))
arg = perform_integral_promotions (arg);
break;