aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-03-30 23:45:00 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-03-30 23:45:00 +0000
commitc6671cbbbc4bccc110b26c24a3eb706f596b7960 (patch)
tree04761024ef3f5044d3fc69d185c9e2024ebf24a9 /gcc/cp/decl.c
parent06ce772609f34249723fe45a49d9681827101aac (diff)
downloadgcc-c6671cbbbc4bccc110b26c24a3eb706f596b7960.zip
gcc-c6671cbbbc4bccc110b26c24a3eb706f596b7960.tar.gz
gcc-c6671cbbbc4bccc110b26c24a3eb706f596b7960.tar.bz2
re PR c++/14724 (Destructor not called on backwards goto past initialization)
PR c++/14724 * decl.c (start_decl_1): Do not decide whether or not to create a new cleanup level until after the type has been completed. PR c++/14763 * pt.c (tsubst_default_argument): Clear current_function_decl. PR c++/14724 * g++.dg/init/goto1.C: New test. PR c++/14763 * g++.dg/template/defarg4.C: New test. From-SVN: r80101
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0b802ff..ce530fa 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -3788,8 +3788,6 @@ start_decl_1 (tree decl)
if (type == error_mark_node)
return;
- maybe_push_cleanup_level (type);
-
if (initialized)
/* Is it valid for this decl to have an initializer at all?
If not, set INITIALIZED to zero, which will indirectly
@@ -3845,6 +3843,14 @@ start_decl_1 (tree decl)
if (! initialized)
DECL_INITIAL (decl) = NULL_TREE;
+
+ /* Create a new scope to hold this declaration if necessary.
+ Whether or not a new scope is necessary cannot be determined
+ until after the type has been completed; if the type is a
+ specialization of a class template it is not until after
+ instantiation has occurred that TYPE_HAS_NONTRIVIAL_DESTRUCTOR
+ will be set correctly. */
+ maybe_push_cleanup_level (type);
}
/* Handle initialization of references. DECL, TYPE, and INIT have the