re PR c++/8688 (ICE with segfault on missing comma in initializer of 2D array.)
authorMark Mitchell <mark@codesourcery.com>
Tue, 3 Dec 2002 09:05:36 +0000 (09:05 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 3 Dec 2002 09:05:36 +0000 (09:05 +0000)
PR c++/8688
* decl.c (reshape_init): Handle erroneous initializers.

PR c++/8688
* g++.dg/init/brace3.C: New test.

From-SVN: r59768

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/brace3.C [new file with mode: 0644]

index befdf121e2cf65de1d95c76197cb1e5ff762c996..2399b18e0e37c54b900f95ad8cd74bd18c5e5585 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/8688
+       * decl.c (reshape_init): Handle erroneous initializers.
+
 2002-12-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/8720
index 1e26b0f112cdd25a822d1c9d107d03e4d18e06dc..d881b832a806ba3b9127ecdaaf7049ddfbeacdfe 100644 (file)
@@ -7793,6 +7793,14 @@ reshape_init (tree type, tree *initp)
   old_init_value = (TREE_CODE (*initp) == TREE_LIST
                    ? TREE_VALUE (*initp) : old_init);
 
+  /* For some parse errors, OLD_INIT_VALUE may be NULL.  */
+  if (!old_init_value)
+    {
+      my_friendly_assert (TREE_CODE (old_init) == TREE_LIST, 20021202);
+      TREE_VALUE (old_init) = error_mark_node;
+      return old_init;
+    }
+
   /* If the initializer is brace-enclosed, pull initializers from the
      enclosed elements.  Advance past the brace-enclosed initializer
      now.  */
index 0c51391ad51ba350cd88c31f42a912681e98c2de..af4f57b01dc319b094813c57b8d5c848dfb14da1 100644 (file)
@@ -1,3 +1,8 @@
+2002-12-03  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/8688
+       * g++.dg/init/brace3.C: New test.
+
 2002-12-02  Kazu Hirata  <kazu@cs.umass.edu>
 
        * gcc.dg/20020210-1.c: Fix a comment typo.
diff --git a/gcc/testsuite/g++.dg/init/brace3.C b/gcc/testsuite/g++.dg/init/brace3.C
new file mode 100644 (file)
index 0000000..0a1ee8f
--- /dev/null
@@ -0,0 +1 @@
+int array[2][1] = { {0} {1} }; // { dg-error "" }