This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR C++/28450 ICE with new of vector and complex types
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 22 Aug 2006 08:41:20 -0700
- Subject: [PATCH] Fix PR C++/28450 ICE with new of vector and complex types
We would ICE if someone did a new of either a vector or a complex type
because build_zero_init does not handle these cases. This fixes the
problem by having build_zero_init handle complex and vector types.
OK? Bootstrapped and tested on i686-linux-gnu with no regressions.
Thanks,
Andrew Pinski
cp/ChangeLog:
* cp/init.c (build_zero_init): Handle VECTOR_TYPE and
COMPLEX_TYPEs.
testsuite/ChangeLog:
* g++.dg/ext/vector4.C
* g++.dg/ext/complex1.C
Index: testsuite/g++.dg/ext/vector4.C
===================================================================
--- testsuite/g++.dg/ext/vector4.C (revision 0)
+++ testsuite/g++.dg/ext/vector4.C (revision 0)
@@ -0,0 +1,6 @@
+/* { dg-options "" } */
+/* { dg-do compile } */
+// Testing if we can do a new of a vector
+// PR C++/28450
+
+void* q = new int __attribute__((vector_size(8))) ();
Index: testsuite/g++.dg/ext/complex1.C
===================================================================
--- testsuite/g++.dg/ext/complex1.C (revision 0)
+++ testsuite/g++.dg/ext/complex1.C (revision 0)
@@ -0,0 +1,6 @@
+/* { dg-options "" } */
+/* { dg-do compile } */
+// Testing if we can do a new of a complex type
+// PR C++/28450
+
+void* q = new __complex__ int ();
Index: cp/init.c
===================================================================
--- cp/init.c (revision 116318)
+++ cp/init.c (working copy)
@@ -178,7 +178,8 @@ build_zero_init (tree type, tree nelts,
items with static storage duration that are not otherwise
initialized are initialized to zero. */
;
- else if (SCALAR_TYPE_P (type))
+ else if (SCALAR_TYPE_P (type)
+ || TREE_CODE (type) == COMPLEX_TYPE)
init = convert (type, integer_zero_node);
else if (CLASS_TYPE_P (type))
{
@@ -248,6 +249,8 @@ build_zero_init (tree type, tree nelts,
/* Build a constructor to contain the initializations. */
init = build_constructor (type, v);
}
+ else if (TREE_CODE (type) == VECTOR_TYPE)
+ init = fold_convert (type, integer_zero_node);
else
gcc_assert (TREE_CODE (type) == REFERENCE_TYPE);