From e5dda97187022d04613b9976398cf4996ddbec79 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 18 Apr 2011 19:54:47 -0400 Subject: [PATCH] re PR c++/48569 (internal compiler error: in build_zero_init_1, at cp/init.c:278) PR c++/48569 * typeck2.c (build_functional_cast): Handle VOID_TYPE. From-SVN: r172680 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck2.c | 6 +++++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/init/void1.C | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/init/void1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cf21fd64a55..ec683a2fc14 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-04-18 Jason Merrill + PR c++/48569 + * typeck2.c (build_functional_cast): Handle VOID_TYPE. + PR c++/48537 * init.c (build_value_init): Handle UNION_TYPE the same. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index f0b67f73e21..49f4e7e7826 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/ChangeLog b/gcc/testsuite/ChangeLog index b8e89094452..497fd4dadae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-04-18 Jason Merrill + * g++.dg/init/void1.C: New. + * g++.dg/cpp0x/union4.C: New. 2011-04-18 Jakub Jelinek diff --git a/gcc/testsuite/g++.dg/init/void1.C b/gcc/testsuite/g++.dg/init/void1.C new file mode 100644 index 00000000000..ed41a90dea3 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/void1.C @@ -0,0 +1,6 @@ +// PR c++/48569 + +int main() +{ + void(); +} -- 2.30.2