semantics.c (begin_stmt_expr): Avoid duplicating the effect of the expression in templates.
* semantics.c (begin_stmt_expr): Avoid duplicating the effect of the expression in templates. (finish_stmt_expr): Likewise. From-SVN: r19469
This commit is contained in:
parent
69fa83cfbb
commit
b69b1501dc
@ -1,3 +1,9 @@
|
||||
Tue Apr 28 13:22:01 1998 Mark Mitchell <mmitchell@usa.net>
|
||||
|
||||
* semantics.c (begin_stmt_expr): Avoid duplicating the effect of
|
||||
the expression in templates.
|
||||
(finish_stmt_expr): Likewise.
|
||||
|
||||
1998-04-28 Brendan Kehoe <brendan@cygnus.com>
|
||||
|
||||
* decl2.c (ambiguous_decl): Fix NAME parm to be a tree, not int.
|
||||
|
@ -761,14 +761,18 @@ finish_parenthesized_expr (expr)
|
||||
return expr;
|
||||
}
|
||||
|
||||
/* Begin a statement-expression. Returns a new RTL_EXPR if
|
||||
appropriate. */
|
||||
/* Begin a statement-expression. The value returned must be passed to
|
||||
finish_stmt_expr. */
|
||||
|
||||
tree
|
||||
begin_stmt_expr ()
|
||||
{
|
||||
keep_next_level ();
|
||||
return processing_template_decl ? NULL_TREE : expand_start_stmt_expr();
|
||||
/* If we're processing_template_decl, then the upcoming compound
|
||||
statement will be chained onto the tree structure, starting at
|
||||
last_tree. We return last_tree so that we can later unhook the
|
||||
compound statement. */
|
||||
return processing_template_decl ? last_tree : expand_start_stmt_expr();
|
||||
}
|
||||
|
||||
/* Finish a statement-expression. RTL_EXPR should be the value
|
||||
@ -807,6 +811,14 @@ finish_stmt_expr (rtl_expr, expr)
|
||||
}
|
||||
else
|
||||
result = expr;
|
||||
|
||||
if (processing_template_decl)
|
||||
{
|
||||
/* Remove the compound statement from the tree structure; it is
|
||||
now saved in the BIND_EXPR. */
|
||||
last_tree = rtl_expr;
|
||||
TREE_CHAIN (last_tree) = NULL_TREE;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
24
gcc/testsuite/g++.old-deja/g++.pt/stmtexpr2.C
Normal file
24
gcc/testsuite/g++.old-deja/g++.pt/stmtexpr2.C
Normal file
@ -0,0 +1,24 @@
|
||||
extern "C" void abort();
|
||||
|
||||
int i;
|
||||
|
||||
void g()
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void f(T)
|
||||
{
|
||||
__extension__ ({g();});
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
f(3.0);
|
||||
if (i != 1)
|
||||
abort();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user