parse.y (primary): Deal with statement-expressions in templates.
* parse.y (primary): Deal with statement-expressions in templates. * pt.c (tsubst_copy): Handle BIND_EXPR. * tree.c (mapcar): Likewise. From-SVN: r17611
This commit is contained in:
parent
0340ed6c77
commit
67da32876e
@ -1,5 +1,10 @@
|
||||
Mon Feb 2 11:24:22 1998 Mark Mitchell <mmitchell@usa.net>
|
||||
|
||||
* parse.y (primary): Deal with statement-expressions in
|
||||
templates.
|
||||
* pt.c (tsubst_copy): Handle BIND_EXPR.
|
||||
* tree.c (mapcar): Likewise.
|
||||
|
||||
* call.c (add_template_candidate_real): Pass extra parameter to
|
||||
fn_type_unification.
|
||||
* cp-tree.h (fn_type_unification): Add parameter.
|
||||
|
1145
gcc/cp/parse.c
1145
gcc/cp/parse.c
File diff suppressed because it is too large
Load Diff
@ -1434,20 +1434,33 @@ primary:
|
||||
YYERROR;
|
||||
}
|
||||
keep_next_level ();
|
||||
$<ttype>$ = expand_start_stmt_expr (); }
|
||||
if (!processing_template_decl)
|
||||
$<ttype>$ = expand_start_stmt_expr ();
|
||||
else
|
||||
$<ttype>$ = NULL_TREE;
|
||||
}
|
||||
compstmt ')'
|
||||
{ tree rtl_exp;
|
||||
if (pedantic)
|
||||
pedwarn ("ANSI C++ forbids braced-groups within expressions");
|
||||
rtl_exp = expand_end_stmt_expr ($<ttype>2);
|
||||
/* The statements have side effects, so the group does. */
|
||||
TREE_SIDE_EFFECTS (rtl_exp) = 1;
|
||||
if (!processing_template_decl)
|
||||
{
|
||||
rtl_exp = expand_end_stmt_expr ($<ttype>2);
|
||||
/* The statements have side effects, so the
|
||||
group does. */
|
||||
TREE_SIDE_EFFECTS (rtl_exp) = 1;
|
||||
}
|
||||
|
||||
if (TREE_CODE ($3) == BLOCK)
|
||||
{
|
||||
/* Make a BIND_EXPR for the BLOCK already made. */
|
||||
$$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
|
||||
NULL_TREE, rtl_exp, $3);
|
||||
if (processing_template_decl)
|
||||
$$ = build (BIND_EXPR, NULL_TREE,
|
||||
NULL_TREE, last_tree, $3);
|
||||
else
|
||||
$$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
|
||||
NULL_TREE, rtl_exp, $3);
|
||||
|
||||
/* Remove the block from the tree at this point.
|
||||
It gets put back at the proper place
|
||||
when the BIND_EXPR is expanded. */
|
||||
|
29
gcc/cp/pt.c
29
gcc/cp/pt.c
@ -4121,12 +4121,33 @@ tsubst_copy (t, args, nargs, in_decl)
|
||||
NULL_TREE);
|
||||
}
|
||||
|
||||
case BIND_EXPR:
|
||||
case COND_EXPR:
|
||||
case MODOP_EXPR:
|
||||
return build_nt
|
||||
(code, tsubst_copy (TREE_OPERAND (t, 0), args, nargs, in_decl),
|
||||
tsubst_copy (TREE_OPERAND (t, 1), args, nargs, in_decl),
|
||||
tsubst_copy (TREE_OPERAND (t, 2), args, nargs, in_decl));
|
||||
{
|
||||
tree r = build_nt
|
||||
(code, tsubst_copy (TREE_OPERAND (t, 0), args, nargs, in_decl),
|
||||
tsubst_copy (TREE_OPERAND (t, 1), args, nargs, in_decl),
|
||||
tsubst_copy (TREE_OPERAND (t, 2), args, nargs, in_decl));
|
||||
|
||||
if (code == BIND_EXPR && !processing_template_decl)
|
||||
{
|
||||
/* This processing should really occur in tsubst_expr,
|
||||
However, tsubst_expr does not recurse into expressions,
|
||||
since it assumes that there aren't any statements
|
||||
inside them. Instead, it simply calls
|
||||
build_expr_from_tree. So, we need to expand the
|
||||
BIND_EXPR here. */
|
||||
tree rtl_exp = expand_start_stmt_expr();
|
||||
tsubst_expr (TREE_OPERAND (r, 1), args, nargs, in_decl);
|
||||
rtl_exp = expand_end_stmt_expr (rtl_exp);
|
||||
TREE_SIDE_EFFECTS (rtl_exp) = 1;
|
||||
return build (BIND_EXPR, TREE_TYPE (rtl_exp),
|
||||
NULL_TREE, rtl_exp, TREE_OPERAND (r, 2));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
case NEW_EXPR:
|
||||
{
|
||||
|
@ -1645,6 +1645,13 @@ mapcar (t, func)
|
||||
case TEMPLATE_TEMPLATE_PARM:
|
||||
return copy_template_template_parm (t);
|
||||
|
||||
case BIND_EXPR:
|
||||
t = copy_node (t);
|
||||
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
|
||||
TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
|
||||
TREE_OPERAND (t, 2) = NULL_TREE;
|
||||
return t;
|
||||
|
||||
case RECORD_TYPE:
|
||||
if (TYPE_PTRMEMFUNC_P (t))
|
||||
return build_ptrmemfunc_type
|
||||
|
Loading…
x
Reference in New Issue
Block a user