This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for 16115


Jason Merrill wrote:

In C++, a value parameter properly belongs to the caller's context, as it
is not destroyed until the end of the full-expression containing the call.
As a result, we pass affected parameters by invisible reference.  We
weren't making this clear in the tree structure, and so the optimizers
cleverly deduced that modifications to the parameter were dead even though
they were necessary for the later destructor to work properly.

Fixed by making the reference explicit.  Tested x86_64-pc-linux-gnu,
applied to trunk.  Test in g++.dg/init/call1.C.

As a result of this, the hackery in the tree inliner to deal with invisible
references can go away; I'm testing that patch now.  We probably want to
make C++ returns by invisible reference similarly explicit.

2004-06-24 Jason Merrill <jason@redhat.com>

	PR c++/16115
	* decl.c (grokparms): Give the PARM_DECL reference type if the
	parameter is passed by invisible reference.



------------------------------------------------------------------------

*** decl.c.~1~ 2004-06-24 15:47:44.000000000 -0400
--- decl.c 2004-06-24 15:46:54.000000000 -0400
*************** grokparms (cp_parameter_declarator *firs
*** 8224,8229 ****
--- 8224,8236 ----
if (type != error_mark_node)
{
+ /* If this type is passed by invisible reference, make the PARM_DECL
+ reflect that so that alias analysis knows that the actual object
+ is external to the function. */
+ if (TREE_ADDRESSABLE (type))
+ decl = build_decl (PARM_DECL, DECL_NAME (decl),
+ build_reference_type (type));


Could we not adjust this in grokdeclarator so that we do not build one PARM_DECL only to throw it away? It gets the "PARM" flag, so it knows it is building a parameter. Or, just reset the type on the existing PARM_DECL?

--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]