This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH: PR 14724 and PR 14763


Mark Mitchell <mark@codesourcery.com> writes:

| This patch fixes two regressions:
| 
| * 14724
| 
|   This was a wrong-code problem involving labels and template classes
|   with destructors.  The destructors were not run in certain
|   situations where they should have been.

Backported to 3.3.4-pre as indicated below.

-- Gaby

Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.3076.2.265
diff -p -r1.3076.2.265 ChangeLog
*** cp/ChangeLog	1 Apr 2004 21:47:59 -0000	1.3076.2.265
--- cp/ChangeLog	1 May 2004 19:54:26 -0000
***************
*** 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: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.965.2.81
diff -p -r1.965.2.81 decl.c
*** cp/decl.c	1 Apr 2004 21:48:04 -0000	1.965.2.81
--- cp/decl.c	1 May 2004 19:54:34 -0000
*************** start_decl_1 (decl)
*** 7872,7879 ****
    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
--- 7872,7877 ----
*************** start_decl_1 (decl)
*** 7929,7934 ****
--- 7927,7940 ----
  
    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: testsuite/g++.dg/init/goto1.C
===================================================================
RCS file: testsuite/g++.dg/init/goto1.C
diff -N testsuite/g++.dg/init/goto1.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/goto1.C	1 May 2004 19:54:35 -0000
***************
*** 0 ****
--- 1,23 ----
+ // 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;
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]