This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [3.2 PATCH] Fix typeid with reference types
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 19 Mar 2003 10:11:27 -0500
- Subject: Re: [3.2 PATCH] Fix typeid with reference types
- References: <20030318182049.C1717@sunsite.ms.mff.cuni.cz> <wvlel54wl7p.fsf@prospero.boston.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Mar 18, 2003 at 02:03:54PM -0500, Jason Merrill wrote:
> That patch is just an optimization. If the testcase breaks without that
> patch, something else is probably broken.
The testcase works just fine when not optimizing. Only at -O1,
it doesn't see through the reference type.
The problem seems to be that although build_vtbl_ref_1 if (optimize)
found the VAR_DECL which initializes it and changed instance, it did
not change basetype and thus incorrect code was generated.
The following patch fixes the testcase on 3.2 branch too, though IMHO
it is better to use the same code as 3.3/trunk.
--- gcc/cp/class.c.jj 2002-11-09 12:39:51.000000000 -0500
+++ gcc/cp/class.c 2003-03-19 10:05:12.000000000 -0500
@@ -436,7 +436,13 @@ build_vtbl_ref_1 (instance, idx)
if (IS_AGGR_TYPE (TREE_TYPE (init))
&& (TREE_CODE (init) == PARM_DECL
|| TREE_CODE (init) == VAR_DECL))
- instance = init;
+ {
+ instance = init;
+ basetype = TREE_TYPE (instance);
+
+ if (TREE_CODE (basetype) == REFERENCE_TYPE)
+ basetype = TREE_TYPE (basetype);
+ }
}
}
}
Jakub