diff options
author | Mark Mitchell <mark@codesourcery.com> | 1999-08-27 04:58:19 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 1999-08-27 04:58:19 +0000 |
commit | e1376b008f646728e2639f795a8af63ac28c2480 (patch) | |
tree | 87aeb110ffe300a105006b507f18cd0169cee5b0 /gcc | |
parent | 078a76c8a059f7a0ff4db84234279e1b0e3ef770 (diff) | |
download | gcc-e1376b008f646728e2639f795a8af63ac28c2480.zip gcc-e1376b008f646728e2639f795a8af63ac28c2480.tar.gz gcc-e1376b008f646728e2639f795a8af63ac28c2480.tar.bz2 |
cp-tree.h (AGGR_INIT_VIA_CTOR_P): New macro.
* cp-tree.h (AGGR_INIT_VIA_CTOR_P): New macro.
* tree.c (build_cplus_new): Set it.
* expr.c (cplus_expand_expr): Use it.
From-SVN: r28915
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 5 | ||||
-rw-r--r-- | gcc/cp/expr.c | 4 | ||||
-rw-r--r-- | gcc/cp/tree.c | 18 |
4 files changed, 26 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0d1bec3..521710c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 1999-08-26 Mark Mitchell <mark@codesourcery.com> + * cp-tree.def (AGGR_INIT_VIA_CTOR_P): New macro. + * tree.c (build_cplus_new): Set it. + * expr.c (cplus_expand_expr): Use it. + * decl.c (store_parm_decls): Reset immediate_size_expand. (finish_function): Likewise. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f544ca3..a9f4b29 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -36,6 +36,7 @@ Boston, MA 02111-1307, USA. */ LOCAL_BINDING_P (in CPLUS_BINDING) ICS_USER_FLAG (in _CONV) CLEANUP_P (in TRY_BLOCK) + AGGR_INIT_VIA_CTOR_P (in AGGR_INIT_EXPR) 1: IDENTIFIER_VIRTUAL_P. TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -1528,6 +1529,10 @@ struct lang_decl #define DELETE_EXPR_USE_VEC(NODE) TREE_LANG_FLAG_1 (NODE) #define LOOKUP_EXPR_GLOBAL(NODE) TREE_LANG_FLAG_0 (NODE) +/* Nonzero if this AGGR_INIT_EXPR provides for initialization via a + constructor call, rather than an ordinary function call. */ +#define AGGR_INIT_VIA_CTOR_P(NODE) TREE_LANG_FLAG_0 (NODE) + /* The TYPE_MAIN_DECL for a class template type is a TYPE_DECL, not a TEMPLATE_DECL. This macro determines whether or not a given class type is really a template type, as opposed to an instantiation or diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c index e85e088..373afe6 100644 --- a/gcc/cp/expr.c +++ b/gcc/cp/expr.c @@ -154,9 +154,7 @@ cplus_expand_expr (exp, target, tmode, modifier) initialization. It is left here to show the choices that exist for C++. */ - if (TREE_CODE (func) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (func, 0)) == FUNCTION_DECL - && DECL_CONSTRUCTOR_P (TREE_OPERAND (func, 0))) + if (AGGR_INIT_VIA_CTOR_P (exp)) { type = build_pointer_type (type); /* Don't clobber a value that might be part of a default diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0b62533..68357c0 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -220,6 +220,7 @@ build_cplus_new (type, init) tree type; tree init; { + tree fn; tree slot; tree rval; @@ -233,9 +234,22 @@ build_cplus_new (type, init) slot = build (VAR_DECL, type); DECL_ARTIFICIAL (slot) = 1; layout_decl (slot, 0); - rval = build (AGGR_INIT_EXPR, type, - TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot); + + /* We split the CALL_EXPR into its function and its arguments here. + Then, in expand_expr, we put them back together. The reason for + this is that this expression might be a default argument + expression. In that case, we need a new temporary every time the + expression is used. That's what break_out_target_exprs does; it + replaces every AGGR_INIT_EXPR with a copy that uses a fresh + temporary slot. Then, expand_expr builds up a call-expression + using the new slot. */ + fn = TREE_OPERAND (init, 0); + rval = build (AGGR_INIT_EXPR, type, fn, TREE_OPERAND (init, 1), slot); TREE_SIDE_EFFECTS (rval) = 1; + AGGR_INIT_VIA_CTOR_P (rval) + = (TREE_CODE (fn) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL + && DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0))); rval = build (TARGET_EXPR, type, slot, rval, NULL_TREE, NULL_TREE); TREE_SIDE_EFFECTS (rval) = 1; |