Another problem caused by the switch to using build_value_init in
build_functional_cast. We need to handle void specifically.
Tested x86_64-pc-linux-gnu, applied to trunk.
commit 43c47963012ad752079f8fd368083feea263236e
Author: Jason Merrill <ja...@redhat.com>
Date: Mon Apr 18 16:20:15 2011 -0700
PR c++/48569
* typeck2.c (build_functional_cast): Handle VOID_TYPE.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index f0b67f7..49f4e7e 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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);
diff --git a/gcc/testsuite/g++.dg/init/void1.C
b/gcc/testsuite/g++.dg/init/void1.C
new file mode 100644
index 0000000..ed41a90
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/void1.C
@@ -0,0 +1,6 @@
+// PR c++/48569
+
+int main()
+{
+ void();
+}