semantics.c (expand_body): Do tree optimization in the function context, too.
authorJason Merrill <jason@redhat.com>
Fri, 2 Aug 2002 11:52:38 +0000 (07:52 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 2 Aug 2002 11:52:38 +0000 (07:52 -0400)
        * semantics.c (expand_body): Do tree optimization in the function
        context, too.

From-SVN: r55982

gcc/cp/ChangeLog
gcc/cp/semantics.c

index 84b1a98acd2324ed5154999b2698a080ede491c6..f9e22ca2388ba4803b0d06f3b1257a032889ad9c 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-02  Jason Merrill  <jason@redhat.com>
+
+       * semantics.c (expand_body): Do tree optimization in the function
+       context, too.
+
 2002-08-01  Neil Booth  <neil@daikokuya.co.uk>
 
        * cp-tree.h: Move all warning and flag declarations to c-common.h.
index 7098aae6c3e2de33c0e0770a7411e02bba286863..58d1647cd681e5d0ecb143718e41d8c653574cec 100644 (file)
@@ -2326,6 +2326,7 @@ expand_body (fn)
 {
   int saved_lineno;
   const char *saved_input_filename;
+  tree saved_function;
 
   /* When the parser calls us after finishing the body of a template
      function, we don't really want to expand the body.  When we're
@@ -2403,21 +2404,23 @@ expand_body (fn)
   if (DECL_EXTERNAL (fn))
     return;
 
-  timevar_push (TV_INTEGRATION);
-
-  /* Optimize the body of the function before expanding it.  */
-  optimize_function (fn);
-
-  timevar_pop (TV_INTEGRATION);
-  timevar_push (TV_EXPAND);
-
   /* Save the current file name and line number.  When we expand the
      body of the function, we'll set LINENO and INPUT_FILENAME so that
      error-mesages come out in the right places.  */
   saved_lineno = lineno;
   saved_input_filename = input_filename;
+  saved_function = current_function_decl;
   lineno = DECL_SOURCE_LINE (fn);
   input_filename = DECL_SOURCE_FILE (fn);
+  current_function_decl = fn;
+
+  timevar_push (TV_INTEGRATION);
+
+  /* Optimize the body of the function before expanding it.  */
+  optimize_function (fn);
+
+  timevar_pop (TV_INTEGRATION);
+  timevar_push (TV_EXPAND);
 
   genrtl_start_function (fn);
   current_function_is_thunk = DECL_THUNK_P (fn);
@@ -2450,6 +2453,7 @@ expand_body (fn)
     DECL_SAVED_TREE (fn) = NULL_TREE;
 
   /* And restore the current source position.  */
+  current_function_decl = saved_function;
   lineno = saved_lineno;
   input_filename = saved_input_filename;
   extract_interface_info ();