re PR c++/26884 (Misleading diagnostic for invalid array initializer)
authorMark Shinwell <shinwell@codesourcery.com>
Wed, 18 Oct 2006 10:57:18 +0000 (10:57 +0000)
committerMark Shinwell <shinwell@gcc.gnu.org>
Wed, 18 Oct 2006 10:57:18 +0000 (10:57 +0000)
        PR c++/26884
        * typeck2.c (digest_init): Raise error upon attempts to
        initialize arrays with variables.

From-SVN: r117854

gcc/cp/ChangeLog
gcc/cp/typeck2.c

index 2358e9bf81856dcf6c498810fc17e3358c04d1d4..356bc25d451ded0a318994e0d8d8de8eef4004b7 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-18  Mark Shinwell  <shinwell@codesourcery.com>
+
+       PR c++/26884
+       * typeck2.c (digest_init): Raise error upon attempts to
+       initialize arrays with variables.
+
 2006-10-17  Lee Millward  <lee.millward@codesourcery.com> 
 
         PR c++/27952
index 12987cfab1e63422d01c6641118498a88d91a125..a3654c00047f5247f1598b4f4a3d1ef310427c23 100644 (file)
@@ -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);