From patchwork Tue Sep 4 19:37:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 181666 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 721D82C00A0 for ; Wed, 5 Sep 2012 05:37:27 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347392248; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=AtbCObL GbQR9ozQik/qTN5jqIJs=; b=FoNK14Hq7LmNAgmAtz7PGTw56Ip0j0yKdRB+KsY iHdl4ivp409k4h06DJgpiwfjIQu2rAwLaJnHshUl6SfswiESqlETHvrm8CRO8uKL w/k4lGhSO0DpdYyg9QuxNIOTYv+ID9FmKX2ExJ0ilibMBnwfsVo8fxEU3WNH/k1s D+Gw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=FKhX9DIyTYwphj/BicPg+gYqL457obZXMZzpfllSD4+Ju2B8GErVCEvTVsm16o b/C9euf6t1fcFI5oE+a1fMvY4w5Dy7je7NbochhT+X4R3CeFI7zNHNpzOzfI11Q3 RYr9REhVvZ9rFRe/Yurn0PpQEgXiJcS7AhZ/BJyNLIf0g=; Received: (qmail 7980 invoked by alias); 4 Sep 2012 19:37:24 -0000 Received: (qmail 7885 invoked by uid 22791); 4 Sep 2012 19:37:22 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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, 04 Sep 2012 19:37:03 +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 q84Jb3v8029080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Sep 2012 15:37:03 -0400 Received: from [10.3.113.46] (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q84Jb2Um005624 for ; Tue, 4 Sep 2012 15:37:03 -0400 Message-ID: <5046585E.7070804@redhat.com> Date: Tue, 04 Sep 2012 15:37:02 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/54198 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 My patch to change check_default_argument to call perform_implicit_conversion_flags in order to get the diagnostics we want there had the undesired side-effect of causing the instantiation of templates that would be used by that conversion, even though the conversion isn't really used. So this patch avoids that by setting cp_unevaluated_context. Tested x86_64-pc-linux-gnu, applying to trunk. commit ce91c2a524880f727a114cc40e0ad94ac6755631 Author: Jason Merrill Date: Tue Sep 4 15:20:32 2012 -0400 PR c++/54198 * decl.c (check_default_argument): Set cp_unevaluated_operand around call to perform_implicit_conversion_flags. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 8b94e26..8024373 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -10575,8 +10575,10 @@ check_default_argument (tree decl, tree arg) A default argument expression is implicitly converted to the parameter type. */ + ++cp_unevaluated_operand; perform_implicit_conversion_flags (decl_type, arg, tf_warning_or_error, LOOKUP_NORMAL); + --cp_unevaluated_operand; if (warn_zero_as_null_pointer_constant && c_inhibit_evaluation_warnings == 0 diff --git a/gcc/testsuite/g++.dg/template/defarg15.C b/gcc/testsuite/g++.dg/template/defarg15.C new file mode 100644 index 0000000..fea3dee --- /dev/null +++ b/gcc/testsuite/g++.dg/template/defarg15.C @@ -0,0 +1,19 @@ +// PR c++/54198 + +template void +refIfNotNull (T* p1) +{ + p1->ref; +} +template struct A +{ + A (T* p1) + { + refIfNotNull (p1); + } +}; +class B; +class C +{ + void getParent (A = 0); +};