This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++] fix bug 386
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++] fix bug 386
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Thu, 10 Aug 2000 13:40:14 +0100
- Organization: Codesourcery LLC
Hi,
Under the obvious rule I've installed the attached patch and testcase
which fixed bug 386. That code is illformed, but we ICE'd before saying so.
The patch reorders an array initializer legality test wrt starting the
initialization.
built & tested on i686-pc-linux-gnu
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-08-10 Nathan Sidwell <nathan@codesourcery.com>
* init.c (build_aggr_init): Reject bogus array initializers
early.
Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/init.c,v
retrieving revision 1.211
diff -c -3 -p -r1.211 init.c
*** init.c 2000/07/10 07:16:18 1.211
--- init.c 2000/08/10 12:21:48
*************** build_aggr_init (exp, init, flags)
*** 1186,1198 ****
/* 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)
{
/* Handle bad initializers like:
class COMPLEX {
--- 1186,1193 ----
/* Must arrange to initialize each element of EXP
from elements of INIT. */
tree itype = init ? TREE_TYPE (init) : NULL_TREE;
!
! if (init && !itype)
{
/* Handle bad initializers like:
class COMPLEX {
*************** build_aggr_init (exp, init, flags)
*** 1206,1213 ****
COMPLEX zees(1.0, 0.0)[10];
}
*/
! error ("bad array initializer");
return error_mark_node;
}
stmt_expr = build_vec_init (exp, exp, array_type_nelts (type), init,
init && same_type_p (TREE_TYPE (init),
--- 1201,1214 ----
COMPLEX zees(1.0, 0.0)[10];
}
*/
! 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),
// Build don't link:
//
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 10 Aug 2000 <nathan@codesourcery.com>
// bug 386.C We ICE'd before emitting a diagnostic when trying to
// initialize a constant non-pod array from something bogus.
struct A
{
A(char);
};
class B
{
const A ary[16];
B (const A ary[]);
};
B::B (const A a[])
: ary(a)
{ // ERROR - bad array initializer
}