From patchwork Tue Aug 16 23:17:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 110250 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 A7A43B6F8B for ; Wed, 17 Aug 2011 09:17:34 +1000 (EST) Received: (qmail 8987 invoked by alias); 16 Aug 2011 23:17:31 -0000 Received: (qmail 8976 invoked by uid 22791); 16 Aug 2011 23:17:30 -0000 X-SWARE-Spam-Status: No, hits=-7.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Tue, 16 Aug 2011 23:17:13 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7GNHDKo008672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Aug 2011 19:17:13 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7GNHCe7001401 for ; Tue, 16 Aug 2011 19:17:13 -0400 Received: from [0.0.0.0] (ovpn-113-29.phx2.redhat.com [10.3.113.29]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p7GNHBOx023451 for ; Tue, 16 Aug 2011 19:17:12 -0400 Message-ID: <4E4AFA77.4070303@redhat.com> Date: Tue, 16 Aug 2011 19:17:11 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110719 Thunderbird/5.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/50054 (ICE after error with init-list) 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 It is possible to run into a situation where we don't know what to do with an initializer-list. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6. commit 1a54ca9d63f7e6453b3327a5699a39696f856a79 Author: Jason Merrill Date: Mon Aug 15 06:15:17 2011 -0400 PR c++/50054 * typeck2.c (cxx_incomplete_type_diagnostic): Handle init_list_type_node. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 0788138..79aa354 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -450,6 +450,12 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, break; case LANG_TYPE: + if (type == init_list_type_node) + { + emit_diagnostic (diag_kind, input_location, 0, + "invalid use of brace-enclosed initializer list"); + break; + } gcc_assert (type == unknown_type_node); if (value && TREE_CODE (value) == COMPONENT_REF) goto bad_member; diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist57.C b/gcc/testsuite/g++.dg/cpp0x/initlist57.C new file mode 100644 index 0000000..d945a46 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist57.C @@ -0,0 +1,8 @@ +// PR c++/50054 +// { dg-options -std=c++0x } + +void g( const int& (a)[1] ) {} // { dg-error "array of references" } + +int main () { + g( { 1, 2 } ); // { dg-error "initializer list" } +}