From patchwork Mon Oct 3 04:29:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 117401 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 556CFB6F7E for ; Mon, 3 Oct 2011 15:30:26 +1100 (EST) Received: (qmail 30459 invoked by alias); 3 Oct 2011 04:30:21 -0000 Received: (qmail 30432 invoked by uid 22791); 3 Oct 2011 04:30:19 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM 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, 03 Oct 2011 04:29:58 +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 p934TwHB015565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 3 Oct 2011 00:29:58 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p934TvE5021361 for ; Mon, 3 Oct 2011 00:29:57 -0400 Received: from [0.0.0.0] (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p934Tubi004259 for ; Mon, 3 Oct 2011 00:29:57 -0400 Message-ID: <4E893A43.3040003@redhat.com> Date: Mon, 03 Oct 2011 00:29:55 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:6.0.2) Gecko/20110906 Thunderbird/6.0.2 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for rejects-valid with C++11 range for 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 The range for code tries to do type deduction for the range for variables when the initializer isn't type dependent, but we don't do auto deduction from an initializer-list, so we shouldn't try to do that for range for, either; if we do we end up complaining about an incomplete type. Tested x86_64-pc-linux-gnu, applying to trunk. commit f65c4d83c5cdd2bff213e4a7cd90258a2e0f4969 Author: Jason Merrill Date: Sun Oct 2 22:53:54 2011 -0400 * parser.c (cp_parser_range_for): Don't try to deduce from {} in a template. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 83d7b71..cabe9aa 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -8688,7 +8688,9 @@ cp_parser_range_for (cp_parser *parser, tree scope, tree init, tree range_decl) { stmt = begin_range_for_stmt (scope, init); finish_range_for_decl (stmt, range_decl, range_expr); - if (!type_dependent_expression_p (range_expr)) + if (!type_dependent_expression_p (range_expr) + /* do_auto_deduction doesn't mess with template init-lists. */ + && !BRACE_ENCLOSED_INITIALIZER_P (range_expr)) do_range_for_auto_deduction (range_decl, range_expr); } else diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for22.C b/gcc/testsuite/g++.dg/cpp0x/range-for22.C new file mode 100644 index 0000000..5fef5e6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for22.C @@ -0,0 +1,5 @@ +// { dg-options -std=c++0x } + +template void f() { + for (auto i: {I} ); +}