cp-tree.def (STMT_EXPR): Fix typo in node name.

* cp-tree.def (STMT_EXPR): Fix typo in node name.

	* dump.c (dump_next_stmt): New function.
	(dequeue_and_dump): Use it.

	* pt.c (tsubst_copy): Make sure to initialize return value for a
	STMT_EXPR, even when processing_template_decl.
	* semantics.c (finish_stmt_expr): A statement-expression whose
	last statement is not an expression-statement has type `void'.

From-SVN: r28804
This commit is contained in:
Mark Mitchell 1999-08-22 18:11:40 +00:00 committed by Mark Mitchell
parent b78639f6f2
commit 9d9169deaa
6 changed files with 60 additions and 6 deletions

View File

@ -1,3 +1,15 @@
1999-08-22 Mark Mitchell <mark@codesourcery.com>
* cp-tree.def (STMT_EXPR): Fix typo in node name.
* dump.c (dump_next_stmt): New function.
(dequeue_and_dump): Use it.
* pt.c (tsubst_copy): Make sure to initialize return value for a
STMT_EXPR, even when processing_template_decl.
* semantics.c (finish_stmt_expr): A statement-expression whose
last statement is not an expression-statement has type `void'.
1999-08-20 Mark Mitchell <mark@codesourcery.com>
* semantics.c (finish_stmt_expr): Fix typo in comment.

View File

@ -238,7 +238,7 @@ DEFTREECODE (HANDLER, "catch_stmt", 'e', 2)
/* A STMT_EXPR represents a statement-expression. The
STMT_EXPR_STMT is the statement given by the expression. */
DEFTREECODE (STMT_EXPR, "cp_stmt_expr", 'e', 1)
DEFTREECODE (STMT_EXPR, "stmt_expr", 'e', 1)
DEFTREECODE (TAG_DEFN, "tag_defn", 'e', 0)

View File

@ -19,9 +19,6 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* TODO: Class types.
Binfos. */
#include "config.h"
#include "system.h"
#include "tree.h"
@ -90,6 +87,7 @@ static void dump_string PROTO ((dump_info_p, const char *));
static void dump_string_field PROTO ((dump_info_p, const char *, const char *));
static void dump_node PROTO ((tree, FILE *));
static void dump_stmt PROTO ((dump_info_p, tree));
static void dump_next_stmt PROTO ((dump_info_p, tree));
/* Add T to the end of the queue of nodes to dump. If DUMP_CHILDREN_P
is non-zero, then its children should be dumped as well. Returns
@ -277,6 +275,16 @@ dump_stmt (di, t)
#define dump_child(field, child) \
queue_and_dump_index (di, field, child, DUMP_CHILDREN)
/* Dump the next statement after STMT. */
static void
dump_next_stmt (di, t)
dump_info_p di;
tree t;
{
dump_child ("next", TREE_CHAIN (t));
}
/* Dump the next node in the queue. */
static void
@ -642,11 +650,13 @@ dequeue_and_dump (di)
dump_child ("ins", ASM_INPUTS (t));
dump_child ("clbr", ASM_CLOBBERS (t));
}
dump_next_stmt (di, t);
break;
case BREAK_STMT:
case CONTINUE_STMT:
dump_stmt (di, t);
dump_next_stmt (di, t);
break;
case CASE_LABEL:
@ -657,18 +667,21 @@ dequeue_and_dump (di)
dump_child ("low", CASE_LOW (t));
dump_child ("high", CASE_HIGH (t));
}
dump_next_stmt (di, t);
break;
case COMPOUND_STMT:
dump_stmt (di, t);
if (dump_children_p)
dump_child ("body", COMPOUND_BODY (t));
dump_next_stmt (di, t);
break;
case DECL_STMT:
dump_stmt (di, t);
if (dump_children_p)
dump_child ("decl", DECL_STMT_DECL (t));
dump_next_stmt (di, t);
break;
case DO_STMT:
@ -678,12 +691,14 @@ dequeue_and_dump (di)
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);
if (dump_children_p)
dump_child ("expr", EXPR_STMT_EXPR (t));
dump_next_stmt (di, t);
break;
case FOR_STMT:
@ -695,12 +710,14 @@ dequeue_and_dump (di)
dump_child ("expr", FOR_EXPR (t));
dump_child ("body", FOR_BODY (t));
}
dump_next_stmt (di, t);
break;
case GOTO_STMT:
dump_stmt (di, t);
if (dump_children_p)
dump_child ("dest", GOTO_DESTINATION (t));
dump_next_stmt (di, t);
break;
case IF_STMT:
@ -711,12 +728,14 @@ dequeue_and_dump (di)
dump_child ("then", THEN_CLAUSE (t));
dump_child ("else", ELSE_CLAUSE (t));
}
dump_next_stmt (di, t);
break;
case RETURN_STMT:
dump_stmt (di, t);
if (dump_children_p)
dump_child ("expr", RETURN_EXPR (t));
dump_next_stmt (di, t);
break;
case SWITCH_STMT:
@ -726,6 +745,7 @@ dequeue_and_dump (di)
dump_child ("cond", SWITCH_COND (t));
dump_child ("body", SWITCH_BODY (t));
}
dump_next_stmt (di, t);
break;
case TRY_BLOCK:
@ -735,6 +755,7 @@ dequeue_and_dump (di)
dump_child ("body", TRY_STMTS (t));
dump_child ("hdlr", TRY_HANDLERS (t));
}
dump_next_stmt (di, t);
break;
case WHILE_STMT:
@ -744,6 +765,7 @@ dequeue_and_dump (di)
dump_child ("cond", WHILE_COND (t));
dump_child ("body", WHILE_BODY (t));
}
dump_next_stmt (di, t);
break;
case INTEGER_CST:
@ -801,6 +823,11 @@ dequeue_and_dump (di)
dump_child ("elts", TREE_OPERAND (t, 1));
break;
case STMT_EXPR:
if (dump_children_p)
dump_child ("stmt", STMT_EXPR_STMT (t));
break;
default:
/* There are no additional fields to print. */
break;

View File

@ -7085,9 +7085,10 @@ tsubst_copy (t, args, complain, in_decl)
tree rtl_expr = begin_stmt_expr ();
tree block = tsubst_expr (STMT_EXPR_STMT (t), args,
complain, in_decl);
r = finish_stmt_expr (rtl_expr, block);
return finish_stmt_expr (rtl_expr, block);
}
return r;
return t;
case COND_EXPR:
case MODOP_EXPR:

View File

@ -1060,6 +1060,10 @@ finish_stmt_expr (rtl_expr, expr)
/* Make a BIND_EXPR for the BLOCK already made. */
if (building_stmt_tree ())
{
/* If the last thing in the statement-expression was not an
expression-statement, then it has type `void'. */
if (!last_expr_type)
last_expr_type = void_type_node;
result = build_min (STMT_EXPR, last_expr_type, last_tree);
/* FIXME: Do we need this? */
TREE_SIDE_EFFECTS (result) = 1;

View File

@ -0,0 +1,10 @@
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
void f ()
{
__extension__ ( { if (3); });
}
template void f<int>();