C++ BUG: base ctor throw regression
Mark Mitchell
mark@codesourcery.com
Tue Nov 30 23:39:00 GMT 1999
Fixed with this patch.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-11-22 Mark Mitchell <mark@codesourcery.com>
* cp-tree.def (CTOR_COMPLETE): New tree node.
(finish_constructor_body): Add it, to mark the end of the
constructor.
(finish_function): Don't call end_protect_partials here.
* ir.texi (CTOR_COMPLETE): Document it.
* semantics.c (expand_stmt): Handle it.
Index: testsuite/g++.old-deja/g++.eh/cleanup2.C
===================================================================
RCS file: /cvs/gcc/egcs/gcc/testsuite/g++.old-deja/g++.eh/cleanup2.C,v
retrieving revision 1.1
diff -c -p -r1.1 cleanup2.C
*** cleanup2.C 1999/11/22 15:51:14 1.1
--- cleanup2.C 1999/11/23 07:27:01
***************
*** 4,11 ****
// make sure we don't call base dtors, if we failed to call the
// base ctor due to exception throwing
- // execution test - XFAIL *-*-*
-
#include <stdio.h>
static bool bad = false;
--- 4,9 ----
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/ChangeLog,v
retrieving revision 1.1429
diff -c -p -r1.1429 ChangeLog
*** ChangeLog 1999/11/23 02:49:40 1.1429
--- ChangeLog 1999/11/23 07:27:13
***************
*** 1,5 ****
--- 1,12 ----
1999-11-22 Mark Mitchell <mark@codesourcery.com>
+ * cp-tree.def (CTOR_COMPLETE): New tree node.
+ (finish_constructor_body): Add it, to mark the end of the
+ constructor.
+ (finish_function): Don't call end_protect_partials here.
+ * ir.texi (CTOR_COMPLETE): Document it.
+ * semantics.c (expand_stmt): Handle it.
+
* cp-tree.def (FUNCTION_NAME): New tree node.
* cp-tree.h (current_function_name_declared): Tweak documentation.
(lang_decl_flags): Add pretty_function_p, adjust dummy.
Index: cp/cp-tree.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.def,v
retrieving revision 1.40
diff -c -p -r1.40 cp-tree.def
*** cp-tree.def 1999/11/23 02:49:40 1.40
--- cp-tree.def 1999/11/23 07:27:13
*************** DEFTREECODE (ASM_STMT, "asm_stmt", 'e',
*** 237,242 ****
--- 237,245 ----
run if an exception is thrown before the end of the enclosing
function. */
DEFTREECODE (SUBOBJECT, "subobject", 'e', 1)
+ /* A CTOR_COMPLETE statements marks the end of the main body of the
+ constructor, not including any function try blocks. */
+ DEFTREECODE (CTOR_COMPLETE, "ctor_complete", 'e', 0)
/* A CLEANUP_STMT marks the point at which a declaration is fully
constructed. If, after this point, the CLEANUP_DECL goes out of
scope, the CLEANUP_EXPR must be run. */
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.507
diff -c -p -r1.507 decl.c
*** decl.c 1999/11/23 02:49:40 1.507
--- decl.c 1999/11/23 07:27:22
*************** finish_constructor_body ()
*** 13293,13298 ****
--- 13293,13302 ----
/* In check_return_expr we translate an empty return from a
constructor to a return of `this'. */
finish_return_stmt (NULL_TREE);
+
+ /* Mark the end of the main constructor body. */
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ add_tree (build_min_nt (CTOR_COMPLETE));
}
/* At the end of every destructor we generate code to restore virtual
*************** finish_function (lineno, flags)
*** 13521,13529 ****
;
else if (DECL_CONSTRUCTOR_P (fndecl))
{
- /* All subobjects have been fully constructed at this point. */
- end_protect_partials ();
-
if (call_poplevel)
do_poplevel ();
}
--- 13525,13530 ----
Index: cp/ir.texi
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/ir.texi,v
retrieving revision 1.20
diff -c -p -r1.20 ir.texi
*** ir.texi 1999/10/27 18:19:17 1.20
--- ir.texi 1999/11/23 07:27:25
*************** following the @code{TREE_CHAIN} link fro
*** 1274,1279 ****
--- 1274,1283 ----
Used to represent a @code{continue} statement. There are no additional
fields.
+ @item CTOR_COMPLETE
+
+ Used to mark the end of the main body of a constructor.
+
@item DECL_STMT
Used to represent a local declaration. The @code{DECL_STMT_DECL} macro
*************** equalit) to @code{CATCH_ALL_TYPE} if thi
*** 1383,1389 ****
In a constructor, these nodes are used to mark the point at which a
subobject of @code{this} is fully constructed. If, after this point, an
! exception is thrown before the constructor finishes executing, the
@code{SUBOBJECT_CLEANUP} must be executed. The cleanups must be
executed in the reverse order in which they appear.
--- 1387,1393 ----
In a constructor, these nodes are used to mark the point at which a
subobject of @code{this} is fully constructed. If, after this point, an
! exception is thrown before a CTOR_COMPLETE statement is encountered, the
@code{SUBOBJECT_CLEANUP} must be executed. The cleanups must be
executed in the reverse order in which they appear.
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.108
diff -c -p -r1.108 semantics.c
*** semantics.c 1999/11/23 02:49:41 1.108
--- semantics.c 1999/11/23 07:27:26
*************** expand_stmt (t)
*** 2268,2273 ****
--- 2268,2278 ----
finish_expr_stmt (EXPR_STMT_EXPR (t));
break;
+ case CTOR_COMPLETE:
+ /* All subobjects have been fully constructed at this point. */
+ end_protect_partials ();
+ break;
+
case DECL_STMT:
{
tree decl;
More information about the Gcc-bugs
mailing list