decl.c (store_parm_decls): Generate cleanup code at semantic-analysis time.
* decl.c (store_parm_decls): Generate cleanup code at semantic-analysis time. Destroy objects in the correct order. From-SVN: r30456
This commit is contained in:
parent
312618c7d0
commit
fe1b3b96ae
@ -1,3 +1,8 @@
|
|||||||
|
1999-11-08 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
* decl.c (store_parm_decls): Generate cleanup code at
|
||||||
|
semantic-analysis time. Destroy objects in the correct order.
|
||||||
|
|
||||||
1999-11-07 Mark Mitchell <mark@codesourcery.com>
|
1999-11-07 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
* cp-tree.h (begin_new_placement): Remove.
|
* cp-tree.h (begin_new_placement): Remove.
|
||||||
|
@ -13163,26 +13163,26 @@ store_parm_decls ()
|
|||||||
next = TREE_CHAIN (parm);
|
next = TREE_CHAIN (parm);
|
||||||
if (TREE_CODE (parm) == PARM_DECL)
|
if (TREE_CODE (parm) == PARM_DECL)
|
||||||
{
|
{
|
||||||
tree cleanup;
|
tree type = TREE_TYPE (parm);
|
||||||
|
|
||||||
if (doing_semantic_analysis_p ())
|
if (doing_semantic_analysis_p ())
|
||||||
{
|
{
|
||||||
|
tree cleanup;
|
||||||
|
|
||||||
if (DECL_NAME (parm) == NULL_TREE
|
if (DECL_NAME (parm) == NULL_TREE
|
||||||
|| TREE_CODE (TREE_TYPE (parm)) != VOID_TYPE)
|
|| TREE_CODE (parm) != VOID_TYPE)
|
||||||
pushdecl (parm);
|
pushdecl (parm);
|
||||||
else
|
else
|
||||||
cp_error ("parameter `%D' declared void", parm);
|
cp_error ("parameter `%D' declared void", parm);
|
||||||
}
|
|
||||||
|
|
||||||
if (! building_stmt_tree ()
|
cleanup = maybe_build_cleanup (parm);
|
||||||
&& (cleanup = maybe_build_cleanup (parm), cleanup))
|
|
||||||
{
|
|
||||||
expand_decl (parm);
|
|
||||||
parms_have_cleanups = 1;
|
|
||||||
|
|
||||||
/* Keep track of the cleanups. */
|
if (cleanup)
|
||||||
cleanups = tree_cons (parm, cleanup, cleanups);
|
cleanups = tree_cons (parm, cleanup, cleanups);
|
||||||
}
|
}
|
||||||
|
else if (type != error_mark_node
|
||||||
|
&& TYPE_NEEDS_DESTRUCTOR (type))
|
||||||
|
parms_have_cleanups = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -13200,9 +13200,6 @@ store_parm_decls ()
|
|||||||
PARM_DECLs that were pushed into scope by the loop above. */
|
PARM_DECLs that were pushed into scope by the loop above. */
|
||||||
DECL_ARGUMENTS (fndecl) = getdecls ();
|
DECL_ARGUMENTS (fndecl) = getdecls ();
|
||||||
storetags (chainon (parmtags, gettags ()));
|
storetags (chainon (parmtags, gettags ()));
|
||||||
|
|
||||||
/* We built up the cleanups in reversed order. */
|
|
||||||
cleanups = nreverse (cleanups);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -13230,14 +13227,10 @@ store_parm_decls ()
|
|||||||
/* Now that we have initialized the parms, we can start their
|
/* Now that we have initialized the parms, we can start their
|
||||||
cleanups. We cannot do this before, since expand_decl_cleanup
|
cleanups. We cannot do this before, since expand_decl_cleanup
|
||||||
should not be called before the parm can be used. */
|
should not be called before the parm can be used. */
|
||||||
if (cleanups && !building_stmt_tree ())
|
|
||||||
while (cleanups)
|
while (cleanups)
|
||||||
{
|
{
|
||||||
if (! expand_decl_cleanup (TREE_PURPOSE (cleanups),
|
finish_decl_cleanup (TREE_PURPOSE (cleanups),
|
||||||
TREE_VALUE (cleanups)))
|
TREE_VALUE (cleanups));
|
||||||
cp_error ("parser lost in parsing declaration of `%D'",
|
|
||||||
TREE_PURPOSE (cleanups));
|
|
||||||
|
|
||||||
cleanups = TREE_CHAIN (cleanups);
|
cleanups = TREE_CHAIN (cleanups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
44
gcc/testsuite/g++.old-deja/g++.other/dtor6.C
Normal file
44
gcc/testsuite/g++.old-deja/g++.other/dtor6.C
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
// Origin: Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
|
extern "C" void abort ();
|
||||||
|
|
||||||
|
int count;
|
||||||
|
|
||||||
|
struct S
|
||||||
|
{
|
||||||
|
S ();
|
||||||
|
S (const S&);
|
||||||
|
~S ();
|
||||||
|
|
||||||
|
int i;
|
||||||
|
};
|
||||||
|
|
||||||
|
S::S ()
|
||||||
|
{
|
||||||
|
i = count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
S::S (const S&)
|
||||||
|
{
|
||||||
|
i = count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
S::~S ()
|
||||||
|
{
|
||||||
|
if (--count != i)
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void f (S, S)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
S s;
|
||||||
|
f (s, s);
|
||||||
|
}
|
||||||
|
return count != 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user