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 cf21fd6..ec683a2 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 f0b67f7..49f4e7e 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 b8e8909..497fd4d 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();
+}