2003-08-18 Nathan Sidwell <nathan@codesourcery.com>
+ PR c++/11957
+ * cp-tree.h (finish_stmt_expr): Add bool parameter.
+ * init.c (finish_init_stmts): Pass true to finish_stmt_expr. Don't
+ adjust the stmt_expr here.
+ (build_vec_init): Use finish_stmt_expr_expr, convert result to
+ array type.
+ * parser.c (cp_parser_primar_expression): Adjust finish_stmt_expr
+ call.
+ * pt.c (tsubst_copy): Likewise.
+ * semantics.c (finish_stmt_expr): Add parameter.
+
* pt.c (instantiate_class_template): Push to class's scope before
tsubsting base.
extern tree finish_non_static_data_member (tree, tree, tree);
extern tree begin_stmt_expr (void);
extern tree finish_stmt_expr_expr (tree);
-extern tree finish_stmt_expr (tree);
+extern tree finish_stmt_expr (tree, bool);
extern tree perform_koenig_lookup (tree, tree);
extern tree finish_call_expr (tree, tree, bool);
extern tree finish_increment_expr (tree, enum tree_code);
{
finish_compound_stmt (compound_stmt);
- stmt_expr = finish_stmt_expr (stmt_expr);
- STMT_EXPR_NO_SCOPE (stmt_expr) = true;
- TREE_USED (stmt_expr) = 1;
+ stmt_expr = finish_stmt_expr (stmt_expr, true);
my_friendly_assert (!building_stmt_tree () == is_global, 20030726);
base = cp_convert (ptype, decay_conversion (base));
/* The code we are generating looks like:
-
+ ({
T* t1 = (T*) base;
T* rval = t1;
ptrdiff_t iterator = maxindex;
} catch (...) {
... destroy elements that were constructed ...
}
- return rval;
+ rval;
+ })
We can omit the try and catch blocks if we know that the
initialization will never throw an exception, or if the array
finish_compound_stmt (try_body);
finish_cleanup_try_block (try_block);
- e = build_vec_delete_1 (rval, m,
- type,
- sfk_base_destructor,
+ e = build_vec_delete_1 (rval, m, type, sfk_base_destructor,
/*use_global_delete=*/0);
finish_cleanup (e, try_block);
}
- /* The value of the array initialization is the address of the
- first element in the array. */
- finish_expr_stmt (rval);
+ /* The value of the array initialization is the array itself, RVAL
+ is a pointer to the first element. */
+ finish_stmt_expr_expr (rval);
stmt_expr = finish_init_stmts (is_global, stmt_expr, compound_stmt);
+
+ /* Now convert make the result have the correct type. */
+ atype = build_pointer_type (atype);
+ stmt_expr = build1 (NOP_EXPR, atype, stmt_expr);
+ stmt_expr = build_indirect_ref (stmt_expr, NULL);
+
current_stmt_tree ()->stmts_are_full_exprs_p = destroy_temps;
return stmt_expr;
}
/* Parse the compound-statement. */
cp_parser_compound_statement (parser, true);
/* Finish up. */
- expr = finish_stmt_expr (expr);
+ expr = finish_stmt_expr (expr, false);
}
else
{
tsubst_expr (STMT_EXPR_STMT (t), args,
complain | tf_stmt_expr_cmpd, in_decl);
- return finish_stmt_expr (stmt_expr);
+ return finish_stmt_expr (stmt_expr, false);
}
return t;
last_expr_type = NULL_TREE;
keep_next_level (1);
-
+
return last_tree;
}
return result;
}
-/* Finish a statement-expression. RTL_EXPR should be the value
- returned by the previous begin_stmt_expr; EXPR is the
- statement-expression. Returns an expression representing the
- statement-expression. */
+/* Finish a statement-expression. EXPR should be the value returned
+ by the previous begin_stmt_expr. Returns an expression
+ representing the statement-expression. */
tree
-finish_stmt_expr (tree rtl_expr)
+finish_stmt_expr (tree rtl_expr, bool has_no_scope)
{
tree result;
tree result_stmt = last_expr_type;
result = build_min (STMT_EXPR, type, last_tree);
TREE_SIDE_EFFECTS (result) = 1;
+ STMT_EXPR_NO_SCOPE (result) = has_no_scope;
last_expr_type = NULL_TREE;