From aa54df09011ad2e4a9f735c04d4f018cad0fe2b2 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 10 Aug 2000 12:32:40 +0000 Subject: [PATCH] init.c (build_aggr_init): Reject bogus array initializers early. * init.c (build_aggr_init): Reject bogus array initializers early. From-SVN: r35605 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/init.c | 17 +++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8912264d2d50..dc4e4c94cfd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-08-10 Nathan Sidwell + + * init.c (build_aggr_init): Reject bogus array initializers + early. + 2000-08-09 Nathan Sidwell * rtti.c (build_dynamic_cast_1): Set "C" linkage for new abi diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d995e060efc5..c35babb1a3db 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1186,13 +1186,8 @@ build_aggr_init (exp, init, flags) /* Must arrange to initialize each element of EXP from elements of INIT. */ tree itype = init ? TREE_TYPE (init) : NULL_TREE; - if (CP_TYPE_QUALS (type) != TYPE_UNQUALIFIED) - { - TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type); - if (init) - TREE_TYPE (init) = TYPE_MAIN_VARIANT (itype); - } - if (init && TREE_TYPE (init) == NULL_TREE) + + if (init && !itype) { /* Handle bad initializers like: class COMPLEX { @@ -1206,9 +1201,15 @@ build_aggr_init (exp, init, flags) COMPLEX zees(1.0, 0.0)[10]; } */ - error ("bad array initializer"); + cp_error ("bad array initializer"); return error_mark_node; } + if (CP_TYPE_QUALS (type) != TYPE_UNQUALIFIED) + { + TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type); + if (init) + TREE_TYPE (init) = TYPE_MAIN_VARIANT (itype); + } stmt_expr = build_vec_init (exp, exp, array_type_nelts (type), init, init && same_type_p (TREE_TYPE (init), TREE_TYPE (exp)));