re PR c++/46688 (g++ requires a function declaration when it should not)
authorJason Merrill <jason@redhat.com>
Fri, 14 Jan 2011 13:08:02 +0000 (08:08 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 14 Jan 2011 13:08:02 +0000 (08:08 -0500)
PR c++/46688
* tree.c (build_vec_init_expr): Handle flexible array
properly.

From-SVN: r168782

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/flexary2.C [new file with mode: 0644]

index a57f978716527248f08a54fcd2bdfb5c09525044..d8416864178f238a7aaf727c2be66b03b28f18f2 100644 (file)
@@ -1,3 +1,9 @@
+2011-01-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46688
+       * tree.c (build_vec_init_expr): Handle flexible array
+       properly.
+
 2011-01-13  Kai Tietz  <kai.tietz@onevision.com>
 
        PR c++/47213
index 213279ac0a92e614327c490d45842db02574406c..813b88d12d2df46f1812e4682a63316f19d60c3f 100644 (file)
@@ -474,7 +474,12 @@ build_vec_init_expr (tree type, tree init)
      what functions are needed.  Here we assume that init is either
      NULL_TREE, void_type_node (indicating value-initialization), or
      another array to copy.  */
-  if (init == void_type_node)
+  if (integer_zerop (array_type_nelts_total (type)))
+    {
+      /* No actual initialization to do.  */;
+      init = NULL_TREE;
+    }
+  else if (init == void_type_node)
     {
       elt_init = build_value_init (inner_type, tf_warning_or_error);
       value_init = true;
index c67c37c43022c89086ba07bf5d3e25dd5cd930de..9851be4425383fa3e1c4a2f61ff256486e5a47ed 100644 (file)
@@ -1,3 +1,7 @@
+2011-01-14  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/ext/flexary2.C: New.
+
 2011-01-14  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/47281
diff --git a/gcc/testsuite/g++.dg/ext/flexary2.C b/gcc/testsuite/g++.dg/ext/flexary2.C
new file mode 100644 (file)
index 0000000..4855b3f
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/46688
+// { dg-options "" }
+
+struct A {
+   A(int);
+};
+
+struct B {
+   B() {}
+   A a[];
+};