C++ PATCH: Yet another array initialization tweak

Mark Mitchell mark@codesourcery.com
Mon Oct 21 09:46:00 GMT 2002


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]
  



More information about the Gcc-patches mailing list