This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR c++/30895: ICE with complex values in template parameter
- From: Simon Martin <simartin at users dot sourceforge dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 28 Feb 2007 07:56:33 +0100
- Subject: [PATCH] Fix PR c++/30895: ICE with complex values in template parameter
Hi all.
The following snippet currently leads to an ICE in cp_tree_equal:
=== cut here ===
template<int> struct A {};
template<typename T> struct B
{
A<T(0i)> a1;
A<T(0i)> a2;
};
=== cut here ===
The problem is that cp_tree_equal is called to compare the two instantiations
of A, but does not handle COMPLEX_CST trees, which leads to the ICE. The
attached patch fixes this by teaching it to handle such trees.
This has been successfully regtested on i686-pc-linux-gnu. Is it OK?
Thanks in advance,
Simon
:ADDPATCH c++:
2007-02-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/30895
* tree.c (cp_tree_equal): Properly handle COMPLEX_CST trees.
Index: gcc/cp/tree.c
===================================================================
--- gcc/cp/tree.c (revision 122335)
+++ gcc/cp/tree.c (working copy)
@@ -1670,6 +1670,10 @@ cp_tree_equal (tree t1, tree t2)
&& !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
TREE_STRING_LENGTH (t1));
+ case COMPLEX_CST:
+ return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
+ && cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
+
case CONSTRUCTOR:
/* We need to do this when determining whether or not two
non-type pointer to member function template arguments
2007-02-27 Simon Martin <simartin@users.sourceforge.net>
PR c++/30895
* g++.dg/parse/template23.C: New test.
/* PR c++/30895 This used to ICE. */
/* { dg-do "compile" } */
template<int> struct A {};
template<typename T> struct B
{
A<T(0i)> a1; /* { dg-error "imaginary constants are a GCC extension" } */
A<T(0i)> a2; /* { dg-error "imaginary constants are a GCC extension" } */
};