From patchwork Wed Mar 16 16:26:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 87283 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 4B104B7011 for ; Thu, 17 Mar 2011 04:11:40 +1100 (EST) Received: (qmail 29103 invoked by alias); 16 Mar 2011 17:11:31 -0000 Received: (qmail 29087 invoked by uid 22791); 16 Mar 2011 17:11:30 -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; Wed, 16 Mar 2011 17:11:23 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2GHBH9g010627 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Mar 2011 13:11:22 -0400 Received: from [127.0.0.1] (ovpn-113-145.phx2.redhat.com [10.3.113.145]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p2GGQ7O6015377 for ; Wed, 16 Mar 2011 12:26:08 -0400 Message-ID: <4D80E49E.8050109@redhat.com> Date: Wed, 16 Mar 2011 12:26:06 -0400 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: A couple of small C++ cleanup PATCHes 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 Conversion of default arguments is an implicit conversion, so it should use LOOKUP_IMPLICIT. A recent bug involved cp_parser_abort_tentative_parse failing to abort because we had already committed to the tentative parse. So let's avoid that in future. Tested x86_64-pc-linux-gnu, applied to trunk. commit 3a0d4ffbbc688196baa21a716a7f74efc172001e Author: Jason Merrill Date: Sat Dec 4 01:25:27 2010 -0500 * call.c (convert_default_arg): Use LOOKUP_IMPLICIT. commit 29e182ba0f92d58fc46c60595de30d2069009c42 Author: Jason Merrill Date: Fri Mar 11 17:53:21 2011 -0500 * parser.c (cp_parser_abort_tentative_parse): Make sure we haven't committed to this tentative parse. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a9fd201..9523fdc 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -21398,6 +21398,8 @@ cp_parser_commit_to_tentative_parse (cp_parser* parser) static void cp_parser_abort_tentative_parse (cp_parser* parser) { + gcc_assert (parser->context->status != CP_PARSER_STATUS_KIND_COMMITTED + || errorcount > 0); cp_parser_simulate_error (parser); /* Now, pretend that we want to see if the construct was successfully parsed. */ diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 499ed03..388f46c 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5803,7 +5803,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum) if (TREE_CODE (arg) == CONSTRUCTOR) { arg = digest_init (type, arg); - arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL, + arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT, ICR_DEFAULT_ARGUMENT, fn, parmnum, tf_warning_or_error); } @@ -5817,7 +5817,7 @@ convert_default_arg (tree type, tree arg, tree fn, int parmnum) are never modified in place. */ if (!CONSTANT_CLASS_P (arg)) arg = unshare_expr (arg); - arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL, + arg = convert_for_initialization (0, type, arg, LOOKUP_IMPLICIT, ICR_DEFAULT_ARGUMENT, fn, parmnum, tf_warning_or_error); arg = convert_for_arg_passing (type, arg);