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));