C++ PATCH: Correct array initializer handling
Mark Mitchell
mark@codesourcery.com
Tue Oct 15 16:55:00 GMT 2002
This patch fixes a regression on the mainline with respect to array
initializers that contain string constants.
Tested on i686-pc-linux-gnu.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2002-10-15 Mark Mitchell <mark@codesourcery.com>
* decl.c (reshape_init): Fix typo.
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.948
diff -c -5 -p -r1.948 decl.c
*** cp/decl.c 11 Oct 2002 19:55:19 -0000 1.948
--- cp/decl.c 15 Oct 2002 22:55:02 -0000
*************** reshape_init (tree type, tree *initp)
*** 7830,7840 ****
*initp = TREE_CHAIN (old_init);
TREE_CHAIN (old_init) = NULL_TREE;
return old_init;
}
! if (TREE_CODE (old_init) == STRING_CST
&& TREE_CODE (type) == ARRAY_TYPE
&& char_type_p (TREE_TYPE (type)))
{
/* [dcl.init.string]
--- 7830,7840 ----
*initp = TREE_CHAIN (old_init);
TREE_CHAIN (old_init) = NULL_TREE;
return old_init;
}
! if (TREE_CODE (old_init_value) == STRING_CST
&& TREE_CODE (type) == ARRAY_TYPE
&& char_type_p (TREE_TYPE (type)))
{
/* [dcl.init.string]
Index: testsuite/g++.dg/init/array6.C
===================================================================
RCS file: testsuite/g++.dg/init/array6.C
diff -N testsuite/g++.dg/init/array6.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/init/array6.C 15 Oct 2002 22:55:09 -0000
***************
*** 0 ****
--- 1,3 ----
+ // { dg-do compile }
+
+ char arr [][4] = { "one", "two" };
More information about the Gcc-patches
mailing list