Commit 9d9169de by Mark Mitchell Committed by Mark Mitchell

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
parent b78639f6
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> 1999-08-20 Mark Mitchell <mark@codesourcery.com>
* semantics.c (finish_stmt_expr): Fix typo in comment. * semantics.c (finish_stmt_expr): Fix typo in comment.
......
...@@ -238,7 +238,7 @@ DEFTREECODE (HANDLER, "catch_stmt", 'e', 2) ...@@ -238,7 +238,7 @@ DEFTREECODE (HANDLER, "catch_stmt", 'e', 2)
/* A STMT_EXPR represents a statement-expression. The /* A STMT_EXPR represents a statement-expression. The
STMT_EXPR_STMT is the statement given by the expression. */ 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) DEFTREECODE (TAG_DEFN, "tag_defn", 'e', 0)
......
...@@ -19,9 +19,6 @@ along with GNU CC; see the file COPYING. If not, write to ...@@ -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, the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
/* TODO: Class types.
Binfos. */
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#include "tree.h" #include "tree.h"
...@@ -90,6 +87,7 @@ static void dump_string PROTO ((dump_info_p, const char *)); ...@@ -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_string_field PROTO ((dump_info_p, const char *, const char *));
static void dump_node PROTO ((tree, FILE *)); static void dump_node PROTO ((tree, FILE *));
static void dump_stmt PROTO ((dump_info_p, tree)); 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 /* 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 is non-zero, then its children should be dumped as well. Returns
...@@ -277,6 +275,16 @@ dump_stmt (di, t) ...@@ -277,6 +275,16 @@ dump_stmt (di, t)
#define dump_child(field, child) \ #define dump_child(field, child) \
queue_and_dump_index (di, field, child, DUMP_CHILDREN) 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. */ /* Dump the next node in the queue. */
static void static void
...@@ -642,11 +650,13 @@ dequeue_and_dump (di) ...@@ -642,11 +650,13 @@ dequeue_and_dump (di)
dump_child ("ins", ASM_INPUTS (t)); dump_child ("ins", ASM_INPUTS (t));
dump_child ("clbr", ASM_CLOBBERS (t)); dump_child ("clbr", ASM_CLOBBERS (t));
} }
dump_next_stmt (di, t);
break; break;
case BREAK_STMT: case BREAK_STMT:
case CONTINUE_STMT: case CONTINUE_STMT:
dump_stmt (di, t); dump_stmt (di, t);
dump_next_stmt (di, t);
break; break;
case CASE_LABEL: case CASE_LABEL:
...@@ -657,18 +667,21 @@ dequeue_and_dump (di) ...@@ -657,18 +667,21 @@ dequeue_and_dump (di)
dump_child ("low", CASE_LOW (t)); dump_child ("low", CASE_LOW (t));
dump_child ("high", CASE_HIGH (t)); dump_child ("high", CASE_HIGH (t));
} }
dump_next_stmt (di, t);
break; break;
case COMPOUND_STMT: case COMPOUND_STMT:
dump_stmt (di, t); dump_stmt (di, t);
if (dump_children_p) if (dump_children_p)
dump_child ("body", COMPOUND_BODY (t)); dump_child ("body", COMPOUND_BODY (t));
dump_next_stmt (di, t);
break; break;
case DECL_STMT: case DECL_STMT:
dump_stmt (di, t); dump_stmt (di, t);
if (dump_children_p) if (dump_children_p)
dump_child ("decl", DECL_STMT_DECL (t)); dump_child ("decl", DECL_STMT_DECL (t));
dump_next_stmt (di, t);
break; break;
case DO_STMT: case DO_STMT:
...@@ -678,12 +691,14 @@ dequeue_and_dump (di) ...@@ -678,12 +691,14 @@ dequeue_and_dump (di)
dump_child ("body", DO_BODY (t)); dump_child ("body", DO_BODY (t));
dump_child ("cond", DO_COND (t)); dump_child ("cond", DO_COND (t));
} }
dump_next_stmt (di, t);
break; break;
case EXPR_STMT: case EXPR_STMT:
dump_stmt (di, t); dump_stmt (di, t);
if (dump_children_p) if (dump_children_p)
dump_child ("expr", EXPR_STMT_EXPR (t)); dump_child ("expr", EXPR_STMT_EXPR (t));
dump_next_stmt (di, t);
break; break;
case FOR_STMT: case FOR_STMT:
...@@ -695,12 +710,14 @@ dequeue_and_dump (di) ...@@ -695,12 +710,14 @@ dequeue_and_dump (di)
dump_child ("expr", FOR_EXPR (t)); dump_child ("expr", FOR_EXPR (t));
dump_child ("body", FOR_BODY (t)); dump_child ("body", FOR_BODY (t));
} }
dump_next_stmt (di, t);
break; break;
case GOTO_STMT: case GOTO_STMT:
dump_stmt (di, t); dump_stmt (di, t);
if (dump_children_p) if (dump_children_p)
dump_child ("dest", GOTO_DESTINATION (t)); dump_child ("dest", GOTO_DESTINATION (t));
dump_next_stmt (di, t);
break; break;
case IF_STMT: case IF_STMT:
...@@ -711,12 +728,14 @@ dequeue_and_dump (di) ...@@ -711,12 +728,14 @@ dequeue_and_dump (di)
dump_child ("then", THEN_CLAUSE (t)); dump_child ("then", THEN_CLAUSE (t));
dump_child ("else", ELSE_CLAUSE (t)); dump_child ("else", ELSE_CLAUSE (t));
} }
dump_next_stmt (di, t);
break; break;
case RETURN_STMT: case RETURN_STMT:
dump_stmt (di, t); dump_stmt (di, t);
if (dump_children_p) if (dump_children_p)
dump_child ("expr", RETURN_EXPR (t)); dump_child ("expr", RETURN_EXPR (t));
dump_next_stmt (di, t);
break; break;
case SWITCH_STMT: case SWITCH_STMT:
...@@ -726,6 +745,7 @@ dequeue_and_dump (di) ...@@ -726,6 +745,7 @@ dequeue_and_dump (di)
dump_child ("cond", SWITCH_COND (t)); dump_child ("cond", SWITCH_COND (t));
dump_child ("body", SWITCH_BODY (t)); dump_child ("body", SWITCH_BODY (t));
} }
dump_next_stmt (di, t);
break; break;
case TRY_BLOCK: case TRY_BLOCK:
...@@ -735,6 +755,7 @@ dequeue_and_dump (di) ...@@ -735,6 +755,7 @@ dequeue_and_dump (di)
dump_child ("body", TRY_STMTS (t)); dump_child ("body", TRY_STMTS (t));
dump_child ("hdlr", TRY_HANDLERS (t)); dump_child ("hdlr", TRY_HANDLERS (t));
} }
dump_next_stmt (di, t);
break; break;
case WHILE_STMT: case WHILE_STMT:
...@@ -744,6 +765,7 @@ dequeue_and_dump (di) ...@@ -744,6 +765,7 @@ dequeue_and_dump (di)
dump_child ("cond", WHILE_COND (t)); dump_child ("cond", WHILE_COND (t));
dump_child ("body", WHILE_BODY (t)); dump_child ("body", WHILE_BODY (t));
} }
dump_next_stmt (di, t);
break; break;
case INTEGER_CST: case INTEGER_CST:
...@@ -801,6 +823,11 @@ dequeue_and_dump (di) ...@@ -801,6 +823,11 @@ dequeue_and_dump (di)
dump_child ("elts", TREE_OPERAND (t, 1)); dump_child ("elts", TREE_OPERAND (t, 1));
break; break;
case STMT_EXPR:
if (dump_children_p)
dump_child ("stmt", STMT_EXPR_STMT (t));
break;
default: default:
/* There are no additional fields to print. */ /* There are no additional fields to print. */
break; break;
......
...@@ -7085,9 +7085,10 @@ tsubst_copy (t, args, complain, in_decl) ...@@ -7085,9 +7085,10 @@ tsubst_copy (t, args, complain, in_decl)
tree rtl_expr = begin_stmt_expr (); tree rtl_expr = begin_stmt_expr ();
tree block = tsubst_expr (STMT_EXPR_STMT (t), args, tree block = tsubst_expr (STMT_EXPR_STMT (t), args,
complain, in_decl); 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 COND_EXPR:
case MODOP_EXPR: case MODOP_EXPR:
......
...@@ -1060,6 +1060,10 @@ finish_stmt_expr (rtl_expr, expr) ...@@ -1060,6 +1060,10 @@ finish_stmt_expr (rtl_expr, expr)
/* Make a BIND_EXPR for the BLOCK already made. */ /* Make a BIND_EXPR for the BLOCK already made. */
if (building_stmt_tree ()) 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); result = build_min (STMT_EXPR, last_expr_type, last_tree);
/* FIXME: Do we need this? */ /* FIXME: Do we need this? */
TREE_SIDE_EFFECTS (result) = 1; TREE_SIDE_EFFECTS (result) = 1;
......
// Build don't link:
// Origin: Mark Mitchell <mark@codesourcery.com>
template <class T>
void f ()
{
__extension__ ( { if (3); });
}
template void f<int>();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment