re PR c++/8287 (GCC3.2: Destructor called for non-constructed local object)
PR c++/8287 * decl.c (finish_destructor_body): Create the label to jump to when returning from a destructor here. (finish_function_body): Rather than here. PR c++/8287 * g++.dg/init/dtor2.C: New test. From-SVN: r58643
This commit is contained in:
parent
7deae97af8
commit
5633b37c1b
|
@ -1,3 +1,10 @@
|
|||
2002-10-29 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
PR c++/8287
|
||||
* decl.c (finish_destructor_body): Create the label to jump to
|
||||
when returning from a destructor here.
|
||||
(finish_function_body): Rather than here.
|
||||
|
||||
2002-10-25 Zack Weinberg <zack@codesourcery.com>
|
||||
|
||||
PR c++/7266
|
||||
|
|
|
@ -14275,6 +14275,10 @@ finish_destructor_body ()
|
|||
{
|
||||
tree exprstmt;
|
||||
|
||||
/* Any return from a destructor will end up here; that way all base
|
||||
and member cleanups will be run when the function returns. */
|
||||
add_stmt (build_stmt (LABEL_STMT, dtor_label));
|
||||
|
||||
/* In a virtual destructor, we must call delete. */
|
||||
if (DECL_VIRTUAL_P (current_function_decl))
|
||||
{
|
||||
|
@ -14347,14 +14351,7 @@ void
|
|||
finish_function_body (compstmt)
|
||||
tree compstmt;
|
||||
{
|
||||
if (processing_template_decl)
|
||||
/* Do nothing now. */;
|
||||
else if (DECL_DESTRUCTOR_P (current_function_decl))
|
||||
/* Any return from a destructor will end up here. Put it before the
|
||||
cleanups so that an explicit return doesn't duplicate them. */
|
||||
add_stmt (build_stmt (LABEL_STMT, dtor_label));
|
||||
|
||||
/* Close the block; in a destructor, run the member cleanups. */
|
||||
/* Close the block. */
|
||||
finish_compound_stmt (0, compstmt);
|
||||
|
||||
if (processing_template_decl)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// { dg-do run }
|
||||
|
||||
extern "C" void abort ();
|
||||
|
||||
struct A
|
||||
{
|
||||
~A();
|
||||
};
|
||||
|
||||
A::~A () {
|
||||
abort ();
|
||||
}
|
||||
|
||||
struct B
|
||||
{
|
||||
~B();
|
||||
};
|
||||
|
||||
B::~B () {
|
||||
if(true) return;
|
||||
A a;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
B b;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue