From patchwork Tue Mar 10 19:08:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 448675 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 689B014016A for ; Wed, 11 Mar 2015 06:08:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=PI6V959O; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=QjYE/7mOwfXoZoJD/ 5a0uohgLQ2n0DdymskgKn6HEyj+rKfRYcidao3l7RdMp8Y6vE/ddRxizD4dRX39f nzmXb2XQm1rabF6H/aCIt9doOPq3X9K0FsOAeqkqotCctUSN3EgWF4Cqlg/dBQLQ 4i2+uxh+3Ia9dsssNqgXnp6VI8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=yYpfaVm4L4SkR6RF5vADT/q Grlk=; b=PI6V959Or4gGwVSdkLq3H4D8LjNsMiAWMR+viZsSF2k2YV0ZpoUAJYS x4+b4H1ESTot/Ih3YkIt+dIEfZjDBSgWHTjiODQHaBzOgJvMsp/5SpUPSXC1VXUY BwsRo3pOVH20qlpWAhy9tv/8UaITXBcLNJ3KCUNb5Y8bIkfgLSNY= Received: (qmail 113597 invoked by alias); 10 Mar 2015 19:08:25 -0000 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 Received: (qmail 113588 invoked by uid 89); 10 Mar 2015 19:08:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 10 Mar 2015 19:08:24 +0000 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t2AJ8Liq012122 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 10 Mar 2015 19:08:22 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t2AJ8KXO026892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 10 Mar 2015 19:08:21 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id t2AJ8JRB017636; Tue, 10 Mar 2015 19:08:20 GMT Received: from [192.168.1.4] (/79.8.209.180) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 10 Mar 2015 12:08:19 -0700 Message-ID: <54FF4121.4010805@oracle.com> Date: Tue, 10 Mar 2015 20:08:17 +0100 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Jason Merrill , "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 65370 References: <54FF12D4.3060603@oracle.com> <54FF19A2.2080501@redhat.com> <54FF23F7.1010605@oracle.com> <54FF337C.808@redhat.com> In-Reply-To: <54FF337C.808@redhat.com> X-IsSubscribed: yes Hi, On 03/10/2015 07:10 PM, Jason Merrill wrote: > Ah. So here we can ignore any template instantiation or > specialization, with a comment that check_explicit_specialization will > handle them. But I suspect that checking the decl itself will be > better; I would expect checking the context to lead you to accept > > template<> class C { > template > C(const C&, bool); > }; > > template C::C(const C&, bool = false); > > Since here C is a specialization of C, but the constructor is not > itself a partial instantiation. Indeed you are right. Therefore I'm finishing testing the below. Thanks! Paolo. //////////////////////// /cp 2015-03-10 Paolo Carlini PR c++/65370 * decl.c (duplicate_decls): Call check_redeclaration_no_default_args only if the location of newdecl doesn't match the location of olddecl. /testsuite 2015-03-10 Paolo Carlini PR c++/65370 * g++.dg/other/default11.C: New. * g++.dg/other/default12.C: Likewise. Index: cp/decl.c =================================================================== --- cp/decl.c (revision 221317) +++ cp/decl.c (working copy) @@ -1922,7 +1922,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool { /* Per C++11 8.3.6/4, default arguments cannot be added in later declarations of a function template. */ - check_redeclaration_no_default_args (newdecl); + if (DECL_SOURCE_LOCATION (newdecl) + != DECL_SOURCE_LOCATION (olddecl)) + check_redeclaration_no_default_args (newdecl); check_default_args (newdecl); Index: testsuite/g++.dg/other/default11.C =================================================================== --- testsuite/g++.dg/other/default11.C (revision 0) +++ testsuite/g++.dg/other/default11.C (working copy) @@ -0,0 +1,11 @@ +// PR c++/65370 + +template class C +{ + template + C(const C&, bool = false); +}; + +template <> +template +C::C(const C&, bool); Index: testsuite/g++.dg/other/default12.C =================================================================== --- testsuite/g++.dg/other/default12.C (revision 0) +++ testsuite/g++.dg/other/default12.C (working copy) @@ -0,0 +1,16 @@ +// PR c++/65370 + +template class C +{ + template + C(const C&, bool = false); +}; + +template<> +class C +{ + template + C(const C&, bool); +}; + +template C::C(const C&, bool = false) { } // { dg-error "default arguments" }