From patchwork Tue Feb 25 18:50:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 324072 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 9649F2C00B0 for ; Wed, 26 Feb 2014 06:08:09 +1100 (EST) 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:content-type; q= dns; s=default; b=cbFv/Ty0z00KfrKiQcZlyy14YftcXrGQwuk+XE3N3TlXfj cyWaOJVk5xNz5bO0VsF8KUqZsUEJsL23q0O92A7Ux9ybNp4VnxSNfmmNz3z6FaDQ 2DoAspjeopJDIsJplMqGB7TKngTnqlS2WH26aANeKqUaBSYBCCfzY/ciTlWLE= 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:content-type; s= default; bh=Mxyzdpa40iLbL1AcjU4wPfdjtGc=; b=mzB9SaeQ4AcltgGT3tKZ v+mAXE0S0x+NcIB/A9SW1YlTzmNcVEDHVJdH3cxMUQxj/yV2Vj8OXOxxZor1N7hu 4Sk9c1qOidQftKJAxIZ2zwMXALAR/TT82fFK5xnNjW03erpqGUatMAoWETNLzTdB N+qK0s7/kHWhaD0kQ0uC7z0= Received: (qmail 15549 invoked by alias); 25 Feb 2014 19:08:02 -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 15540 invoked by uid 89); 25 Feb 2014 19:08:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Feb 2014 19:08:00 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1PIo9Gb001868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 25 Feb 2014 13:50:09 -0500 Received: from [10.10.116.19] ([10.10.116.19]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1PIo7bY031980 for ; Tue, 25 Feb 2014 13:50:08 -0500 Message-ID: <530CE5DF.1030307@redhat.com> Date: Tue, 25 Feb 2014 13:50:07 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/60328 (alias template equivalence) My initial implementation of alias template equivalence failed to handle the case here, of a nested alias being equivalent to its enclosing class template. Fixed by implementing the rules in the standard more directly. Tested x86_64-pc-linux-gnu, applying to trunk. commit f7c8a08b6ee7f9229be75efa909d6673c77a4fd3 Author: Jason Merrill Date: Tue Feb 25 11:15:36 2014 -0500 DR 1286 PR c++/60328 * pt.c (get_underlying_template): Fix equivalence calculation. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bd59142..4a9fa71 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5185,9 +5185,12 @@ get_underlying_template (tree tmpl) tree sub = TYPE_TI_TEMPLATE (result); if (PRIMARY_TEMPLATE_P (sub) && (num_innermost_template_parms (tmpl) - == num_innermost_template_parms (sub)) - && same_type_p (result, TREE_TYPE (sub))) + == num_innermost_template_parms (sub))) { + tree alias_args = INNERMOST_TEMPLATE_ARGS + (template_parms_to_args (DECL_TEMPLATE_PARMS (tmpl))); + if (!comp_template_args (TYPE_TI_ARGS (result), alias_args)) + break; /* The alias type is equivalent to the pattern of the underlying template, so strip the alias. */ tmpl = sub; diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C new file mode 100644 index 0000000..fef9818 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-dr1286b.C @@ -0,0 +1,12 @@ +// PR c++/60328 +// { dg-require-effective-target c++11 } + +template +struct Foo +{ + template + using Bar = Foo<_TT, _RR...>; + + using Normal = Foo<_Rest...>; + using Fail = Bar<_Rest...>; +};