aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2003-01-16 22:43:52 -0500
committerJason Merrill <jason@gcc.gnu.org>2003-01-16 22:43:52 -0500
commita48cccead82f5aa6007fc204008e2882fe8aa059 (patch)
treecbcc387aa476669c2a479b4a4b04423368aa1188 /gcc/cp
parent3d042e770b6b46116c9b45eb924b67a47178dbd8 (diff)
downloadgcc-a48cccead82f5aa6007fc204008e2882fe8aa059.zip
gcc-a48cccead82f5aa6007fc204008e2882fe8aa059.tar.gz
gcc-a48cccead82f5aa6007fc204008e2882fe8aa059.tar.bz2
re PR c++/8564 (ICE in find_function_data, at function.c:329)
PR c++/8564 * init.c (build_vec_init): Re-add maxindex parm. (perform_member_init, build_aggr_init): Pass it. (build_new_1): Pass it. Use an incomplete array type for full_type. * typeck.c (build_modify_expr): Pass it. * cp-tree.h: Adjust. From-SVN: r61422
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/cp-tree.h2
-rw-r--r--gcc/cp/init.c34
-rw-r--r--gcc/cp/typeck.c2
4 files changed, 33 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 54d66be..d50b3d6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2003-01-16 Jason Merrill <jason@redhat.com>
+
+ PR c++/8564
+ * init.c (build_vec_init): Re-add maxindex parm.
+ (perform_member_init, build_aggr_init): Pass it.
+ (build_new_1): Pass it. Use an incomplete array type for full_type.
+ * typeck.c (build_modify_expr): Pass it.
+ * cp-tree.h: Adjust.
+
2003-01-16 Jeffrey D. Oldham <oldham@codesourcery.com>
* cp-tree.h (tsubst_copy_and_build): New declaration.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9d06763..4b29211 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3957,7 +3957,7 @@ extern tree build_member_call (tree, tree, tree);
extern tree build_offset_ref (tree, tree);
extern tree resolve_offset_ref (tree);
extern tree build_new (tree, tree, tree, int);
-extern tree build_vec_init (tree, tree, int);
+extern tree build_vec_init (tree, tree, tree, int);
extern tree build_x_delete (tree, int, tree);
extern tree build_delete (tree, tree, special_function_kind, int, int);
extern void push_base_cleanups (void);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 964ee1e..c822516 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -353,7 +353,8 @@ perform_member_init (tree member, tree init)
&& TREE_CODE (TREE_TYPE (TREE_VALUE (init))) == ARRAY_TYPE)
{
/* Initialization of one array from another. */
- finish_expr_stmt (build_vec_init (decl, TREE_VALUE (init), 1));
+ finish_expr_stmt (build_vec_init (decl, NULL_TREE, TREE_VALUE (init),
+ /* from_array=*/1));
}
else
finish_expr_stmt (build_aggr_init (decl, init, 0));
@@ -1115,7 +1116,7 @@ build_aggr_init (exp, init, flags)
TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
if (itype && cp_type_quals (itype) != TYPE_UNQUALIFIED)
TREE_TYPE (init) = TYPE_MAIN_VARIANT (itype);
- stmt_expr = build_vec_init (exp, init,
+ stmt_expr = build_vec_init (exp, NULL_TREE, init,
init && same_type_p (TREE_TYPE (init),
TREE_TYPE (exp)));
TREE_READONLY (exp) = was_const;
@@ -2155,6 +2156,7 @@ build_new_1 (exp)
tree placement, init;
tree type, true_type, size, rval, t;
tree full_type;
+ tree outer_nelts = NULL_TREE;
tree nelts = NULL_TREE;
tree alloc_call, alloc_expr, alloc_node;
tree alloc_fn;
@@ -2184,12 +2186,11 @@ build_new_1 (exp)
if (TREE_CODE (type) == ARRAY_REF)
{
has_array = 1;
- nelts = TREE_OPERAND (type, 1);
+ nelts = outer_nelts = TREE_OPERAND (type, 1);
type = TREE_OPERAND (type, 0);
- full_type = cp_build_binary_op (MINUS_EXPR, nelts, integer_one_node);
- full_type = build_index_type (full_type);
- full_type = build_cplus_array_type (type, full_type);
+ /* Use an incomplete array type to avoid VLA headaches. */
+ full_type = build_cplus_array_type (type, NULL_TREE);
}
else
full_type = type;
@@ -2379,7 +2380,11 @@ build_new_1 (exp)
pedwarn ("ISO C++ forbids initialization in array new");
if (has_array)
- init_expr = build_vec_init (init_expr, init, 0);
+ init_expr
+ = build_vec_init (init_expr,
+ cp_build_binary_op (MINUS_EXPR, outer_nelts,
+ integer_one_node),
+ init, /*from_array=*/0);
else if (TYPE_NEEDS_CONSTRUCTING (type))
init_expr = build_special_member_call (init_expr,
complete_ctor_identifier,
@@ -2710,6 +2715,9 @@ get_temp_regvar (type, init)
initialization of a vector of aggregate types.
BASE is a reference to the vector, of ARRAY_TYPE.
+ MAXINDEX is the maximum index of the array (one less than the
+ number of elements). It is only used if
+ TYPE_DOMAIN (TREE_TYPE (BASE)) == NULL_TREE.
INIT is the (possibly NULL) initializer.
FROM_ARRAY is 0 if we should init everything with INIT
@@ -2720,8 +2728,8 @@ get_temp_regvar (type, init)
but use assignment instead of initialization. */
tree
-build_vec_init (base, init, from_array)
- tree base, init;
+build_vec_init (base, maxindex, init, from_array)
+ tree base, init, maxindex;
int from_array;
{
tree rval;
@@ -2741,9 +2749,11 @@ build_vec_init (base, init, from_array)
tree try_block = NULL_TREE;
tree try_body = NULL_TREE;
int num_initialized_elts = 0;
- tree maxindex = array_type_nelts (TREE_TYPE (base));
- if (maxindex == error_mark_node)
+ if (TYPE_DOMAIN (atype))
+ maxindex = array_type_nelts (atype);
+
+ if (maxindex == NULL_TREE || maxindex == error_mark_node)
return error_mark_node;
if (init
@@ -2934,7 +2944,7 @@ build_vec_init (base, init, from_array)
sorry
("cannot initialize multi-dimensional array with initializer");
elt_init = build_vec_init (build1 (INDIRECT_REF, type, base),
- 0, 0);
+ 0, 0, 0);
}
else
elt_init = build_aggr_init (build1 (INDIRECT_REF, type, base),
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 2c896d4..57d95ad 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5380,7 +5380,7 @@ build_modify_expr (lhs, modifycode, rhs)
from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
? 1 + (modifycode != INIT_EXPR): 0;
- return build_vec_init (lhs, newrhs, from_array);
+ return build_vec_init (lhs, NULL_TREE, newrhs, from_array);
}
if (modifycode == INIT_EXPR)