Blame SOURCES/gcc32-c++-scope-nesting.patch

4ac4fd
2004-08-13  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	Revert:
4ac4fd
	2003-03-17  Jason Merrill  <jason@redhat.com>
4ac4fd
	* decl.c (finish_function): Don't skip a block.
4ac4fd
4ac4fd
2004-08-12  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	2002-12-16  Jason Merrill  <jason@redhat.com>
4ac4fd
	* c-semantics.c (add_scope_stmt): Abort if the end SCOPE_STMT
4ac4fd
	doesn't match the begin SCOPE_STMT in partialness.
4ac4fd
4ac4fd
2004-08-12  Alexandre Oliva  <aoliva@redhat.com>
4ac4fd
4ac4fd
	2002-12-16  Jason Merrill  <jason@redhat.com>
4ac4fd
	* semantics.c (do_pushlevel): Call pushlevel after adding the
4ac4fd
	SCOPE_STMT.
4ac4fd
	(do_poplevel): Call poplevel before adding the SCOPE_STMT.
4ac4fd
	* parse.y (function_body): Go back to using compstmt.
4ac4fd
	* decl.c (pushdecl): Skip another level to get to the parms level.
4ac4fd
4ac4fd
--- gcc/c-semantics.c 17 Jan 2003 17:49:35 -0000 1.40.2.2.8.2
4ac4fd
+++ gcc/c-semantics.c 12 Aug 2004 09:16:00 -0000
4ac4fd
@@ -143,6 +143,8 @@ add_scope_stmt (begin_p, partial_p)
4ac4fd
     }
4ac4fd
   else
4ac4fd
     {
4ac4fd
+      if (partial_p != SCOPE_PARTIAL_P (TREE_PURPOSE (top)))
4ac4fd
+	abort ();
4ac4fd
       TREE_VALUE (top) = ss;
4ac4fd
       *stack_ptr = TREE_CHAIN (top);
4ac4fd
     }
4ac4fd
--- gcc/cp/decl.c 25 Mar 2003 20:01:38 -0000 1.866.2.36.4.15
4ac4fd
+++ gcc/cp/decl.c 12 Aug 2004 09:16:20 -0000
4ac4fd
@@ -4218,6 +4218,9 @@ pushdecl (x)
4ac4fd
 		     them there.  */
4ac4fd
 		  struct binding_level *b = current_binding_level->level_chain;
4ac4fd
 
4ac4fd
+		  /* Skip the ctor/dtor cleanup level.  */
4ac4fd
+		  b = b->level_chain;
4ac4fd
+
4ac4fd
 		  /* ARM $8.3 */
4ac4fd
 		  if (b->parm_flag == 1)
4ac4fd
 		    {
4ac4fd
--- gcc/cp/decl.c	2004-08-13 01:32:01.000000000 -0300
4ac4fd
+++ gcc/cp/decl.c	2004-08-12 21:55:06.000000000 -0300
4ac4fd
@@ -14375,7 +14375,8 @@
4ac4fd
 	     the function so we know that their lifetime always ends with a
4ac4fd
 	     return; see g++.dg/opt/nrv6.C.  We could be more flexible if
4ac4fd
 	     we were to do this optimization in tree-ssa.  */
4ac4fd
-	  && (outer = BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl)),
4ac4fd
+	  /* Skip the artificial function body block.  */
4ac4fd
+	  && (outer = BLOCK_SUBBLOCKS (BLOCK_SUBBLOCKS (DECL_INITIAL (fndecl))),
4ac4fd
 	      chain_member (r, BLOCK_VARS (outer))))
4ac4fd
 	{
4ac4fd
 	  
4ac4fd
--- gcc/cp/parse.y 17 Jan 2003 17:49:55 -0000 1.248.2.5.4.1.2.3
4ac4fd
+++ gcc/cp/parse.y 12 Aug 2004 09:16:22 -0000
4ac4fd
@@ -775,15 +775,10 @@ eat_saved_input:
4ac4fd
 	;
4ac4fd
 
4ac4fd
 /* The outermost block of a function really begins before the
4ac4fd
-   mem-initializer-list, so we open one there and suppress the one that
4ac4fd
-   actually corresponds to the curly braces.  */
4ac4fd
+   mem-initializer-list, so we open one there, too.  */
4ac4fd
 function_body:
4ac4fd
-	  .begin_function_body ctor_initializer_opt save_lineno '{'
4ac4fd
-		{ $<ttype>$ = begin_compound_stmt (/*has_no_scope=*/1); }
4ac4fd
-	  compstmtend 
4ac4fd
+	  .begin_function_body ctor_initializer_opt compstmt
4ac4fd
                 {
4ac4fd
-		  STMT_LINENO ($<ttype>5) = $3;
4ac4fd
-		  finish_compound_stmt (/*has_no_scope=*/1, $<ttype>5);
4ac4fd
 		  finish_function_body ($1);
4ac4fd
 		}
4ac4fd
 	;
4ac4fd
--- gcc/cp/semantics.c 25 Mar 2003 20:01:39 -0000 1.252.2.6.8.3
4ac4fd
+++ gcc/cp/semantics.c 12 Aug 2004 09:16:23 -0000
4ac4fd
@@ -125,14 +125,17 @@ do_poplevel ()
4ac4fd
     {
4ac4fd
       tree scope_stmts = NULL_TREE;
4ac4fd
 
4ac4fd
-      if (!processing_template_decl)
4ac4fd
-	scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
4ac4fd
-
4ac4fd
       block = poplevel (kept_level_p (), 1, 0);
4ac4fd
-      if (block && !processing_template_decl)
4ac4fd
+      if (!processing_template_decl)
4ac4fd
 	{
4ac4fd
-	  SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
4ac4fd
-	  SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
4ac4fd
+	  /* This needs to come after the poplevel so that partial scopes
4ac4fd
+	     are properly nested.  */
4ac4fd
+	  scope_stmts = add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
4ac4fd
+	  if (block)
4ac4fd
+	    {
4ac4fd
+	      SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts)) = block;
4ac4fd
+	      SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts)) = block;
4ac4fd
+	    }
4ac4fd
 	}
4ac4fd
     }
4ac4fd
 
4ac4fd
@@ -146,9 +149,9 @@ do_pushlevel ()
4ac4fd
 {
4ac4fd
   if (stmts_are_full_exprs_p ())
4ac4fd
     {
4ac4fd
-      pushlevel (0);
4ac4fd
       if (!processing_template_decl)
4ac4fd
 	add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
4ac4fd
+      pushlevel (0);
4ac4fd
     }
4ac4fd
 }
4ac4fd