This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Yet another array initialization tweak
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org, Ritzert at t-online dot de
- Date: Mon, 21 Oct 2002 09:37:17 -0700
- Subject: C++ PATCH: Yet another array initialization tweak
- Reply-to: mark at codesourcery dot com
Here is yet another array-initialization fix.
Tested on i686-pc-linux-gnu, applied on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-10-21 Mark Mitchell <mark@codesourcery.com>
* decl.c (reshape_init): Tweak handling of character arrays.
2002-10-21 Mark Mitchell <mark@codesourcery.com>
* g++.dg/init/array6.C: Add additional tests.
Index: testsuite/g++.dg/init/array6.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/init/array6.C,v
retrieving revision 1.1
diff -c -p -r1.1 array6.C
*** testsuite/g++.dg/init/array6.C 15 Oct 2002 23:59:23 -0000 1.1
--- testsuite/g++.dg/init/array6.C 21 Oct 2002 16:42:34 -0000
***************
*** 1,3 ****
--- 1,7 ----
// { dg-do compile }
char arr [][4] = { "one", "two" };
+ const char arr2[][4] = { "one", "two" };
+ signed char arr3[][4] = { "one", "two" };
+ const unsigned char arr4[][4] = { "one", "two" };
+ volatile wchar_t arr5[][4] = { L"one", L"two" };
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.951
diff -c -p -r1.951 decl.c
*** cp/decl.c 19 Oct 2002 03:14:11 -0000 1.951
--- cp/decl.c 21 Oct 2002 16:42:37 -0000
*************** reshape_init (tree type, tree *initp)
*** 7838,7844 ****
if (TREE_CODE (old_init_value) == STRING_CST
&& TREE_CODE (type) == ARRAY_TYPE
! && char_type_p (TREE_TYPE (type)))
{
/* [dcl.init.string]
--- 7838,7844 ----
if (TREE_CODE (old_init_value) == STRING_CST
&& TREE_CODE (type) == ARRAY_TYPE
! && char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type))))
{
/* [dcl.init.string]