]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/14724 (Destructor not called on backwards goto past initialization)
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Sat, 1 May 2004 19:57:28 +0000 (19:57 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Sat, 1 May 2004 19:57:28 +0000 (19:57 +0000)
Backport from gcc-3_4-branch:
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.

From-SVN: r81394

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/g++.dg/init/goto1.C

index 02082405ab293d0e61f92e9ad6177e629b28cc2d..abc8892cf406e54e67b238fa8c813371cb41d19c 100644 (file)
@@ -1,3 +1,11 @@
+2004-05-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+
+       Backport from gcc-3_4-branch:
+       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.
+
 2004-04-01  Richard Henderson  <rth@redhat.com>
 
         PR c++/14804
index 91ef96afb9ee0296d6b664df410b6b20f3cbcb55..e17254ef4f3db0e4ef1d3bfd4613a868661cf858 100644 (file)
@@ -7872,8 +7872,6 @@ start_decl_1 (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
@@ -7929,6 +7927,14 @@ start_decl_1 (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
index b0a0c5253b6406dba2e90b4ce50d61007f10926e..c086efd542880700b29f5ace2ac34a36e1822de9 100644 (file)
@@ -12,12 +12,12 @@ struct C {
 int main(int, char **) {
   {
     int i = 0;
- again:
 again:
     C<int> v;
     if (++i < 10)
       goto again;
   }
-
+  
   return j;
 }