[PATCH] Fix PR c++/26884

Mark Shinwell shinwell@codesourcery.com
Wed Oct 18 11:29:00 GMT 2006


Mark Mitchell wrote:
> This version looks fine -- but watch your line-wrapping; it looks like 
> you're close to exceeding the 72-column width.  If you are, make sure 
> you wrap appropriately before check-in, e.g.:
> 
>   if (TREE_CODE ...
>       && TREE_CODE (init) ...)
> 
>   error ("array ... "
>          "brace-enclosed initializer");
> 
> Thanks!
> 

Tested on mainline and 4.1 with no regressions on i686-pc-linux-gnu.
Applied thus on mainline and 4.1.

Mark

--


2006-10-18  Mark Shinwell  <shinwell@codesourcery.com>

         PR c++/26884
         * typeck2.c (digest_init): Raise error upon attempts to
         initialize arrays with variables.


Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c    (revision 117853)
+++ gcc/cp/typeck2.c    (working copy)
@@ -733,6 +733,15 @@ digest_init (tree type, tree init)

           return error_mark_node;
         }
+
+      if (TREE_CODE (type) == ARRAY_TYPE
+         && TREE_CODE (init) != CONSTRUCTOR)
+       {
+         error ("array must be initialized with a brace-enclosed"
+                " initializer");
+         return error_mark_node;
+       }
+
        return convert_for_initialization (NULL_TREE, type, init,
                                          LOOKUP_NORMAL | LOOKUP_ONLYCONVERTING,
                                          "initialization", NULL_TREE, 0);



More information about the Gcc-patches mailing list