c-common.def (RETURN_STMT): Remove.

* c-common.def (RETURN_STMT): Remove.
        * c-common.h (RETURN_STMT_EXPR): Remove.
        (c_expand_return, build_return_stmt): Remove.
        (c_common_stmt_codes): Remove RETURN_STMT.
        * c-dump.c (dump_next_stmt): Remove.
        (c_dump_tree): Remove RETURN_STMT.
        * c-decl.c (finish_function): Use c_finish_return.
        * c-parse.in (stmt): Likewise.
        * c-gimplify.c (gimplify_return_stmt): Remove.
        (c_gimplify_expr): Remove RETURN_STMT.
        * c-pretty-print.c (pp_c_statement): Likewise.
        * c-semantics.c (build_return_stmt): Remove.
        * c-tree.h (c_finish_return): Declare.
        * c-typeck.c (c_finish_return): Rename from c_expand_return.
        Return void.  Build RETURN_EXPR directly.
        * tree-dump.h (dump_next_stmt): Remove.
cp/
        * dump.c (cp_dump_tree): Don't use dump_next_stmt.
        * parser.c (cp_parser_jump_statement): Update commentary.
        * pt.c (tsubst_expr): Use RETURN_EXPR.
        * semantics.c (finish_return_stmt): Likewise.
        (finalize_nrv_r): Likewise.
        * typeck.c, typeck2.c: Update file start commentary.

From-SVN: r83461
This commit is contained in:
Richard Henderson 2004-06-21 16:30:30 -07:00 committed by Richard Henderson
parent 0b4da8a182
commit 5088b05874
20 changed files with 55 additions and 118 deletions

View File

@ -1,3 +1,22 @@
2004-06-21 Richard Henderson <rth@redhat.com>
* c-common.def (RETURN_STMT): Remove.
* c-common.h (RETURN_STMT_EXPR): Remove.
(c_expand_return, build_return_stmt): Remove.
(c_common_stmt_codes): Remove RETURN_STMT.
* c-dump.c (dump_next_stmt): Remove.
(c_dump_tree): Remove RETURN_STMT.
* c-decl.c (finish_function): Use c_finish_return.
* c-parse.in (stmt): Likewise.
* c-gimplify.c (gimplify_return_stmt): Remove.
(c_gimplify_expr): Remove RETURN_STMT.
* c-pretty-print.c (pp_c_statement): Likewise.
* c-semantics.c (build_return_stmt): Remove.
* c-tree.h (c_finish_return): Declare.
* c-typeck.c (c_finish_return): Rename from c_expand_return.
Return void. Build RETURN_EXPR directly.
* tree-dump.h (dump_next_stmt): Remove.
2004-06-21 Zack Weinberg <zack@codesourcery.com>
* c-decl.c (start_function): Don't call make_decl_rtl. Don't

View File

@ -2,7 +2,7 @@
additional tree codes used in the GNU C++ compiler (see tree.def
for the standard codes).
Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998,
1999, 2000, 2001 Free Software Foundation, Inc.
1999, 2000, 2001, 2004 Free Software Foundation, Inc.
Written by Benjamin Chelf <chelf@codesourcery.com>
This file is part of GCC.
@ -49,10 +49,6 @@ DEFTREECODE (WHILE_STMT, "while_stmt", 'e', 2)
DO_COND, respectively. */
DEFTREECODE (DO_STMT, "do_stmt", 'e', 2)
/* Used to represent a 'return' statement. The operand is
RETURN_STMT_EXPR. */
DEFTREECODE (RETURN_STMT, "return_stmt", 'e', 1)
/* Used to represent a 'break' statement. */
DEFTREECODE (BREAK_STMT, "break_stmt", 'e', 0)

View File

@ -930,11 +930,6 @@ extern void finish_file (void);
#define DO_COND(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 0)
#define DO_BODY(NODE) TREE_OPERAND (DO_STMT_CHECK (NODE), 1)
/* RETURN_STMT accessors. These give the expression associated with a
return statement, and whether it should be ignored when expanding
(as opposed to inlining). */
#define RETURN_STMT_EXPR(NODE) TREE_OPERAND (RETURN_STMT_CHECK (NODE), 0)
/* EXPR_STMT accessor. This gives the expression associated with an
expression statement. */
#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
@ -978,7 +973,7 @@ enum c_tree_code {
#define c_common_stmt_codes \
EXPR_STMT, DECL_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, RETURN_STMT, \
WHILE_STMT, DO_STMT, \
BREAK_STMT, CONTINUE_STMT, SWITCH_STMT
/* TRUE if a code represents a statement. The front end init
@ -1012,13 +1007,11 @@ extern int anon_aggr_type_p (tree);
extern void emit_local_var (tree);
extern void make_rtl_for_local_static (tree);
extern tree c_expand_return (tree);
extern tree do_case (tree, tree);
extern tree build_stmt (enum tree_code, ...);
extern tree build_case_label (tree, tree, tree);
extern tree build_continue_stmt (void);
extern tree build_break_stmt (void);
extern tree build_return_stmt (tree);
extern void c_expand_asm_operands (tree, tree, tree, tree, int, location_t);

View File

@ -6242,7 +6242,7 @@ finish_function (void)
DEFAULT_MAIN_RETURN;
#else
if (flag_isoc99)
c_expand_return (integer_zero_node);
c_finish_return (integer_zero_node);
#endif
}
}

View File

@ -1,5 +1,5 @@
/* Tree-dumping functionality for C-family languages.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>
This file is part of GCC.
@ -37,14 +37,6 @@ dump_stmt (dump_info_p di, tree t)
dump_int (di, "line", locus->line);
}
/* Dump the next statement after STMT. */
void
dump_next_stmt (dump_info_p di, tree t)
{
dump_child ("next", TREE_CHAIN (t));
}
/* Dump any C-specific tree codes and attributes of common codes. */
bool
@ -66,26 +58,22 @@ c_dump_tree (void *dump_info, tree t)
case BREAK_STMT:
case CONTINUE_STMT:
dump_stmt (di, t);
dump_next_stmt (di, t);
break;
case DECL_STMT:
dump_stmt (di, t);
dump_child ("decl", DECL_STMT_DECL (t));
dump_next_stmt (di, t);
break;
case DO_STMT:
dump_stmt (di, t);
dump_child ("body", DO_BODY (t));
dump_child ("cond", DO_COND (t));
dump_next_stmt (di, t);
break;
case EXPR_STMT:
dump_stmt (di, t);
dump_child ("expr", EXPR_STMT_EXPR (t));
dump_next_stmt (di, t);
break;
case FOR_STMT:
@ -94,27 +82,18 @@ c_dump_tree (void *dump_info, tree t)
dump_child ("cond", FOR_COND (t));
dump_child ("expr", FOR_EXPR (t));
dump_child ("body", FOR_BODY (t));
dump_next_stmt (di, t);
break;
case RETURN_STMT:
dump_stmt (di, t);
dump_child ("expr", RETURN_STMT_EXPR (t));
dump_next_stmt (di, t);
break;
case SWITCH_STMT:
dump_stmt (di, t);
dump_child ("cond", SWITCH_COND (t));
dump_child ("body", SWITCH_BODY (t));
dump_next_stmt (di, t);
break;
case WHILE_STMT:
dump_stmt (di, t);
dump_child ("cond", WHILE_COND (t));
dump_child ("body", WHILE_BODY (t));
dump_next_stmt (di, t);
break;
case STMT_EXPR:

View File

@ -2,7 +2,7 @@
by the C-based front ends. The structure of gimplified, or
language-independent, trees is dictated by the grammar described in this
file.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Lowering of expressions contributed by Sebastian Pop <s.pop@laposte.net>
Re-written to support lowering of whole function trees, documentation
and miscellaneous cleanups by Diego Novillo <dnovillo@redhat.com>
@ -467,17 +467,6 @@ gimplify_switch_stmt (tree *stmt_p)
return GS_ALL_DONE;
}
/* Genericize a RETURN_STMT by turning it into a RETURN_EXPR. */
static enum gimplify_status
gimplify_return_stmt (tree *stmt_p)
{
tree expr = RETURN_STMT_EXPR (*stmt_p);
expr = build1 (RETURN_EXPR, void_type_node, expr);
*stmt_p = expr;
return GS_OK;
}
/* Gimplifies a DECL_STMT node *STMT_P by making any necessary allocation
and initialization explicit. */
@ -614,9 +603,6 @@ c_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED)
case EXPR_STMT:
return gimplify_expr_stmt (expr_p);
case RETURN_STMT:
return gimplify_return_stmt (expr_p);
case DECL_STMT:
return gimplify_decl_stmt (expr_p);

View File

@ -2242,9 +2242,9 @@ stmt:
else
add_stmt (build_continue_stmt ()); }
| RETURN ';'
{ stmt_count++; c_expand_return (NULL_TREE); }
{ stmt_count++; c_finish_return (NULL_TREE); }
| RETURN expr ';'
{ stmt_count++; c_expand_return ($2); }
{ stmt_count++; c_finish_return ($2); }
| asm_stmt
| GOTO identifier ';'
{ tree decl;

View File

@ -1982,23 +1982,6 @@ pp_c_statement (c_pretty_printer *pp, tree stmt)
pp_needs_newline (pp) = true;
break;
case RETURN_STMT:
{
tree e = RETURN_STMT_EXPR (stmt);
pp_c_identifier (pp, "return");
pp_c_whitespace (pp);
if (e)
{
if (TREE_CODE (e) == INIT_EXPR
&& TREE_CODE (TREE_OPERAND (e, 0)) == RESULT_DECL)
e = TREE_OPERAND (e, 1);
pp_expression (pp, e);
}
pp_c_semicolon (pp);
pp_needs_newline (pp) = true;
}
break;
case DECL_STMT:
pp_declaration (pp, DECL_STMT_DECL (stmt));
pp_needs_newline (pp) = true;

View File

@ -247,14 +247,6 @@ emit_local_var (tree decl)
}
}
/* Build the node for a return statement and return it. */
tree
build_return_stmt (tree expr)
{
return (build_stmt (RETURN_STMT, expr));
}
/* Build a break statement node and return it. */
tree

View File

@ -272,6 +272,7 @@ extern void c_finish_for_stmt (tree, tree);
extern tree c_begin_stmt_expr (void);
extern tree c_finish_stmt_expr (tree);
extern void c_finish_expr_stmt (tree);
extern void c_finish_return (tree);
extern tree build_offsetof (tree, tree);
/* Set to 0 at beginning of a function definition, set to 1 if

View File

@ -23,11 +23,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* This file is part of the C front end.
It contains routines to build C expressions given their operands,
including computing the types of the result, C-specific error checks,
and some optimization.
There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
and to process initializations in declarations (since they work
like a strange sort of assignment). */
and some optimization. */
#include "config.h"
#include "system.h"
@ -6248,12 +6244,11 @@ c_expand_asm_operands (tree string, tree outputs, tree inputs,
emit_queue ();
}
/* Expand a C `return' statement.
RETVAL is the expression for what to return,
or a null pointer for `return;' with no value. */
/* Generate a C `return' statement. RETVAL is the expression for what
to return, or a null pointer for `return;' with no value. */
tree
c_expand_return (tree retval)
void
c_finish_return (tree retval)
{
tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl));
@ -6282,7 +6277,7 @@ c_expand_return (tree retval)
current_function_returns_value = 1;
if (t == error_mark_node)
return NULL_TREE;
return;
inner = t = convert (TREE_TYPE (res), t);
@ -6340,7 +6335,7 @@ c_expand_return (tree retval)
retval = build (MODIFY_EXPR, TREE_TYPE (res), res, t);
}
return add_stmt (build_return_stmt (retval));
add_stmt (build_stmt (RETURN_EXPR, retval));
}
struct c_switch {

View File

@ -1,3 +1,12 @@
2004-06-21 Richard Henderson <rth@redhat.com>
* dump.c (cp_dump_tree): Don't use dump_next_stmt.
* parser.c (cp_parser_jump_statement): Update commentary.
* pt.c (tsubst_expr): Use RETURN_EXPR.
* semantics.c (finish_return_stmt): Likewise.
(finalize_nrv_r): Likewise.
* typeck.c, typeck2.c: Update file start commentary.
2004-06-21 Richard Henderson <rth@redhat.com>
* semantics.c (finish_expr_stmt): Call verify_sequence_points.

View File

@ -1,6 +1,6 @@
/* C++-specific tree lowering bits; see also c-gimplify.c and tree-gimple.c.
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Jason Merrill <jason@redhat.com>
This file is part of GCC.

View File

@ -366,14 +366,12 @@ cp_dump_tree (void* dump_info, tree t)
dump_string (di, "cleanup");
dump_child ("body", TRY_STMTS (t));
dump_child ("hdlr", TRY_HANDLERS (t));
dump_next_stmt (di, t);
break;
case EH_SPEC_BLOCK:
dump_stmt (di, t);
dump_child ("body", EH_SPEC_STMTS (t));
dump_child ("raises", EH_SPEC_RAISES (t));
dump_next_stmt (di, t);
break;
case PTRMEM_CST:
@ -397,19 +395,16 @@ cp_dump_tree (void* dump_info, tree t)
dump_stmt (di, t);
dump_child ("parm", HANDLER_PARMS (t));
dump_child ("body", HANDLER_BODY (t));
dump_next_stmt (di, t);
break;
case MUST_NOT_THROW_EXPR:
dump_stmt (di, t);
dump_child ("body", TREE_OPERAND (t, 0));
dump_next_stmt (di, t);
break;
case USING_STMT:
dump_stmt (di, t);
dump_child ("nmsp", USING_STMT_NAMESPACE (t));
dump_next_stmt (di, t);
break;
case CLEANUP_STMT:
@ -417,7 +412,6 @@ cp_dump_tree (void* dump_info, tree t)
dump_child ("decl", CLEANUP_DECL (t));
dump_child ("expr", CLEANUP_EXPR (t));
dump_child ("body", CLEANUP_BODY (t));
dump_next_stmt (di, t);
break;
case IF_STMT:
@ -425,7 +419,6 @@ cp_dump_tree (void* dump_info, tree t)
dump_child ("cond", IF_COND (t));
dump_child ("then", THEN_CLAUSE (t));
dump_child ("else", ELSE_CLAUSE (t));
dump_next_stmt (di, t);
break;
default:

View File

@ -6241,7 +6241,7 @@ cp_parser_for_init_statement (cp_parser* parser)
jump-statement:
goto * expression ;
Returns the new BREAK_STMT, CONTINUE_STMT, RETURN_STMT, or GOTO_EXPR. */
Returns the new BREAK_STMT, CONTINUE_STMT, RETURN_EXPR, or GOTO_EXPR. */
static tree
cp_parser_jump_statement (cp_parser* parser)

View File

@ -7773,8 +7773,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
(TREE_OPERAND (t, 0), args));
break;
case RETURN_STMT:
finish_return_stmt (tsubst_expr (RETURN_STMT_EXPR (t),
case RETURN_EXPR:
finish_return_stmt (tsubst_expr (TREE_OPERAND (t, 0),
args, complain, in_decl));
break;

View File

@ -3,8 +3,8 @@
building RTL. These routines are used both during actual parsing
and during the instantiation of template functions.
Copyright (C) 1998, 1999, 2000, 2001, 2002,
2003, 2004 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
Written by Mark Mitchell (mmitchell@usa.net) based on code found
formerly in parse.y and pt.c.
@ -667,7 +667,7 @@ finish_return_stmt (tree expr)
}
}
r = build_stmt (RETURN_STMT, expr);
r = build_stmt (RETURN_EXPR, expr);
r = maybe_cleanup_point_expr (r);
r = add_stmt (r);
finish_stmt ();
@ -3009,8 +3009,8 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
/* Change all returns to just refer to the RESULT_DECL; this is a nop,
but differs from using NULL_TREE in that it indicates that we care
about the value of the RESULT_DECL. */
else if (TREE_CODE (*tp) == RETURN_STMT)
RETURN_STMT_EXPR (*tp) = dp->result;
else if (TREE_CODE (*tp) == RETURN_EXPR)
TREE_OPERAND (*tp, 0) = dp->result;
/* Change all cleanups for the NRV to only run when an exception is
thrown. */
else if (TREE_CODE (*tp) == CLEANUP_STMT
@ -3052,7 +3052,7 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data)
}
/* Called from finish_function to implement the named return value
optimization by overriding all the RETURN_STMTs and pertinent
optimization by overriding all the RETURN_EXPRs and pertinent
CLEANUP_STMTs and replacing all occurrences of VAR with RESULT, the
RESULT_DECL for the function. */

View File

@ -24,11 +24,7 @@ Boston, MA 02111-1307, USA. */
/* This file is part of the C++ front end.
It contains routines to build C++ expressions given their operands,
including computing the types of the result, C and C++ specific error
checks, and some optimization.
There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
and to process initializations in declarations (since they work
like a strange sort of assignment). */
checks, and some optimization. */
#include "config.h"
#include "system.h"

View File

@ -26,11 +26,7 @@ Boston, MA 02111-1307, USA. */
/* This file is part of the C++ front end.
It contains routines to build C++ expressions given their operands,
including computing the types of the result, C and C++ specific error
checks, and some optimization.
There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
and to process initializations in declarations (since they work
like a strange sort of assignment). */
checks, and some optimization. */
#include "config.h"
#include "system.h"

View File

@ -83,7 +83,6 @@ extern void dump_pointer (dump_info_p, const char *, void *);
extern void dump_int (dump_info_p, const char *, int);
extern void dump_string (dump_info_p, const char *);
extern void dump_stmt (dump_info_p, tree);
extern void dump_next_stmt (dump_info_p, tree);
extern void queue_and_dump_index (dump_info_p, const char *, tree, int);
extern void queue_and_dump_type (dump_info_p, tree);
extern void dump_function (enum tree_dump_index, tree);