Commit c6671cbb by Mark Mitchell Committed by Mark Mitchell

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
parent 06ce7726
2004-03-30 Mark Mitchell <mark@codesourcery.com>
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.
2004-03-30 Zack Weinberg <zack@codesourcery.com> 2004-03-30 Zack Weinberg <zack@codesourcery.com>
* name-lookup.c, parser.c: Use new shorter form of GTY markers. * name-lookup.c, parser.c: Use new shorter form of GTY markers.
......
...@@ -3788,8 +3788,6 @@ start_decl_1 (tree decl) ...@@ -3788,8 +3788,6 @@ start_decl_1 (tree decl)
if (type == error_mark_node) if (type == error_mark_node)
return; return;
maybe_push_cleanup_level (type);
if (initialized) if (initialized)
/* Is it valid for this decl to have an initializer at all? /* Is it valid for this decl to have an initializer at all?
If not, set INITIALIZED to zero, which will indirectly If not, set INITIALIZED to zero, which will indirectly
...@@ -3845,6 +3843,14 @@ start_decl_1 (tree decl) ...@@ -3845,6 +3843,14 @@ start_decl_1 (tree decl)
if (! initialized) if (! initialized)
DECL_INITIAL (decl) = NULL_TREE; 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 /* Handle initialization of references. DECL, TYPE, and INIT have the
......
...@@ -5902,6 +5902,10 @@ tsubst_default_argument (tree fn, tree type, tree arg) ...@@ -5902,6 +5902,10 @@ tsubst_default_argument (tree fn, tree type, tree arg)
/* FN is already the desired FUNCTION_DECL. */ /* FN is already the desired FUNCTION_DECL. */
push_access_scope (fn); push_access_scope (fn);
/* The default argument expression should not be considered to be
within the scope of FN. Since push_access_scope sets
current_function_decl, we must explicitly clear it here. */
current_function_decl = NULL_TREE;
arg = tsubst_expr (arg, DECL_TI_ARGS (fn), arg = tsubst_expr (arg, DECL_TI_ARGS (fn),
tf_error | tf_warning, NULL_TREE); tf_error | tf_warning, NULL_TREE);
......
2004-03-30 Mark Mitchell <mark@codesourcery.com>
PR c++/14724
* g++.dg/init/goto1.C: New test.
PR c++/14763
* g++.dg/template/defarg4.C: New test.
2004-03-30 Hartmut Penner <hpenner@de.ibm.com> 2004-03-30 Hartmut Penner <hpenner@de.ibm.com>
* gcc.dg/altivec-11.c: Extend test for more valid cases. * gcc.dg/altivec-11.c: Extend test for more valid cases.
......
// PR c++/14724
// { dg-do run }
int j;
template <class T>
struct C {
C() { ++j; }
~C() { --j; }
};
int main(int, char **) {
{
int i = 0;
again:
C<int> v;
if (++i < 10)
goto again;
}
return j;
}
// PR c++/14763
struct A {
int get() const {}
static A *foo();
};
template<bool> struct S {
S(unsigned int = A::foo()->get()) ;
};
void foo() throw() {
S<false> f;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment