From patchwork Mon Apr 18 23:55:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 91896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3B2D01007DF for ; Tue, 19 Apr 2011 09:56:30 +1000 (EST) Received: (qmail 4183 invoked by alias); 18 Apr 2011 23:56:26 -0000 Received: (qmail 4164 invoked by uid 22791); 18 Apr 2011 23:56:25 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Apr 2011 23:55:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3INtr0r025764 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Apr 2011 19:55:53 -0400 Received: from [127.0.0.1] (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3INtqbN021303 for ; Mon, 18 Apr 2011 19:55:52 -0400 Message-ID: <4DACCF87.6060107@redhat.com> Date: Mon, 18 Apr 2011 16:55:51 -0700 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/48569 (ICE on void()) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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(); +}