diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 84b1a98acd2..f9e22ca2388 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2002-08-02 Jason Merrill + + * semantics.c (expand_body): Do tree optimization in the function + context, too. + 2002-08-01 Neil Booth * cp-tree.h: Move all warning and flag declarations to c-common.h. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7098aae6c3e..58d1647cd68 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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,6 +2404,16 @@ expand_body (fn) if (DECL_EXTERNAL (fn)) return; + /* 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. */ @@ -2411,14 +2422,6 @@ expand_body (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; - lineno = DECL_SOURCE_LINE (fn); - input_filename = DECL_SOURCE_FILE (fn); - 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 ();