re PR c++/48569 (internal compiler error: in build_zero_init_1, at cp/init.c:278)
authorJason Merrill <jason@redhat.com>
Mon, 18 Apr 2011 23:54:47 +0000 (19:54 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 18 Apr 2011 23:54:47 +0000 (19:54 -0400)
PR c++/48569
* typeck2.c (build_functional_cast): Handle VOID_TYPE.

From-SVN: r172680

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

index cf21fd64a55e8475e883e0e2467350817858a7d3..ec683a2fc147915653496bbd5672771a729d74f1 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/48569
+       * typeck2.c (build_functional_cast): Handle VOID_TYPE.
+
        PR c++/48537
        * init.c (build_value_init): Handle UNION_TYPE the same.
 
index f0b67f73e21a0238539f73c4f58a8fdea49c53cf..49f4e7e78267325d6d71b335edc5c3c4eb2d6695 100644 (file)
@@ -1566,7 +1566,11 @@ build_functional_cast (tree exp, tree parms, tsubst_flags_t complain)
   if (! MAYBE_CLASS_TYPE_P (type))
     {
       if (parms == NULL_TREE)
-       return build_value_init (type, complain);
+       {
+         if (VOID_TYPE_P (type))
+           return void_zero_node;
+         return build_value_init (type, complain);
+       }
 
       /* This must build a C cast.  */
       parms = build_x_compound_expr_from_list (parms, ELK_FUNC_CAST, complain);
index b8e89094452642629121edff232d13f5b672f5e5..497fd4dadaee755fd2fd8985bdb77c95857777b9 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-18  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/init/void1.C: New.
+
        * g++.dg/cpp0x/union4.C: New.
 
 2011-04-18  Jakub Jelinek  <jakub@redhat.com>
diff --git a/gcc/testsuite/g++.dg/init/void1.C b/gcc/testsuite/g++.dg/init/void1.C
new file mode 100644 (file)
index 0000000..ed41a90
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/48569
+
+int main()
+{
+  void();
+}