pt.c (cur_stmt_expr): Move from tsubst_expr.

* pt.c (cur_stmt_expr): Move from tsubst_expr.
        (tsubst_expr) <case STMT_EXPR>: Move ...
        (tsubst_copy_and_build): ... here.

From-SVN: r87385
This commit is contained in:
Richard Henderson 2004-09-11 21:45:59 -07:00 committed by Richard Henderson
parent 97b7c168e5
commit 0fe0caa6d9
3 changed files with 35 additions and 18 deletions

View File

@ -1,3 +1,10 @@
2004-09-11 Richard Henderson <rth@redhat.com>
PR c++/17404
* pt.c (cur_stmt_expr): Move from tsubst_expr.
(tsubst_expr) <case STMT_EXPR>: Move ...
(tsubst_copy_and_build): ... here.
2004-09-10 Zack Weinberg <zack@codesourcery.com>
* cp-tree.h (interface_only, interface_unknown): Delete declarations;

View File

@ -67,6 +67,11 @@ static GTY(()) tree current_tinst_level;
static GTY(()) tree saved_access_scope;
/* Live only within one (recursive) call to tsubst_expr. We use
this to pass the statement expression node from the STMT_EXPR
to the EXPR_STMT that is its result. */
static tree cur_stmt_expr;
/* A map from local variable declarations in the body of the template
presently being instantiated to the corresponding instantiated
local variables. */
@ -7790,11 +7795,6 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
static tree
tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
{
/* Live only within one (recursive) call to tsubst_expr. We use
this to pass the statement expression node from the STMT_EXPR
to the EXPR_STMT that is its result. */
static tree cur_stmt_expr;
tree stmt, tmp;
if (t == NULL_TREE || t == error_mark_node)
@ -7825,19 +7825,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
args, complain, in_decl));
break;
case STMT_EXPR:
{
tree old_stmt_expr = cur_stmt_expr;
tree stmt_expr = begin_stmt_expr ();
cur_stmt_expr = stmt_expr;
tsubst_expr (STMT_EXPR_STMT (t), args, complain, in_decl);
stmt_expr = finish_stmt_expr (stmt_expr, false);
cur_stmt_expr = old_stmt_expr;
return stmt_expr;
}
case EXPR_STMT:
tmp = tsubst_expr (EXPR_STMT_EXPR (t), args, complain, in_decl);
if (EXPR_STMT_STMT_EXPR_RESULT (t))
@ -8626,6 +8613,19 @@ tsubst_copy_and_build (tree t,
case OFFSETOF_EXPR:
return fold_offsetof (RECUR (TREE_OPERAND (t, 0)));
case STMT_EXPR:
{
tree old_stmt_expr = cur_stmt_expr;
tree stmt_expr = begin_stmt_expr ();
cur_stmt_expr = stmt_expr;
tsubst_expr (STMT_EXPR_STMT (t), args, complain, in_decl);
stmt_expr = finish_stmt_expr (stmt_expr, false);
cur_stmt_expr = old_stmt_expr;
return stmt_expr;
}
default:
return tsubst_copy (t, args, complain, in_decl);
}

View File

@ -0,0 +1,10 @@
// PR c++/17404
// { dg-do compile }
// { dg-options "" }
template <int> void foo ()
{
__builtin_expect (({0;}), 1);
}
template void foo<1> ();