Message ID | 20211001134643.1941700-1-ppalka@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B1743857C7E for <patchwork@sourceware.org>; Fri, 1 Oct 2021 13:47:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B1743857C7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633096037; bh=vDG/Sf69ZsgIYokOyC9gsJXtgEws57ruP6BlF8SHf08=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ckQ+6EJhhgYjstGu9DDmWvh9rmebIOMR/UNKnIcwVJoQku+XjUBpg0MBu2cDEnBPV owR6FD4rAZ8DKU4CX5uWmRQ97TY5MkDUM5A0WCHhZOypB27MwcId+AOa0p+jaKueOQ bMwAy6Lo1AYd/MqYhLRMKpphiHLwCtc0m+HInEgM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 0C7093858C2C for <gcc-patches@gcc.gnu.org>; Fri, 1 Oct 2021 13:46:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C7093858C2C Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-GUqQamEhOSSv6VsWUXBWCA-1; Fri, 01 Oct 2021 09:46:47 -0400 X-MC-Unique: GUqQamEhOSSv6VsWUXBWCA-1 Received: by mail-qv1-f71.google.com with SMTP id h25-20020a0cab19000000b0037a49d15c93so13191088qvb.22 for <gcc-patches@gcc.gnu.org>; Fri, 01 Oct 2021 06:46:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vDG/Sf69ZsgIYokOyC9gsJXtgEws57ruP6BlF8SHf08=; b=BfbwE89A8QqR8ERitlt7rXfuGKXD9/Ws4TZiN/ZbNKknCJAmob/1SM7txjHUC3UsnX GhjF4qqj51kaeXddRyCjhEwAx9kzLgI+qbcayREARTYqCREUtr2Y8XjI0/ySKisiUg2/ fVNRizmMrY2MCeNWD+wn4gHBuZuml1UiF+6o2HvyKQSETEdZcIQXKOaFi0sFSB+oqpcV 9WUTlxXLg4gr2QBZCIrjZpdXlGL/v9IqIoc9Xxm4ToRotKIYrgGpECl0lA4iMTeTVWOC eIgsWIG/dbA4X2QnbkSMKSYWr5TJzr2zr2vwFob02+bZc991rgjtbcS6C6zuZeZ5Ffpu bvgg== X-Gm-Message-State: AOAM532Q7U9AEk+0vvE6Bkf9qkIwnXRWRxo9sUfjZAQIk5mDCAdul95s QssjbIZJPKvZKs5pmQ4IUoL+s1Gz6uFmBx64KbSZPnrHdQ69QxbWg0d8LQVXYOdwZine5m/JBo/ G13hMeul7iPrHCqK5/PIpIH1vQ+geGiEO7g53ogzJEUnmOzh98lNbe20T7OmsEtq4iBE= X-Received: by 2002:ac8:764a:: with SMTP id i10mr13050461qtr.206.1633096006101; Fri, 01 Oct 2021 06:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjF9fWHp2n/tpriG7pDrz/l3Ys/4BXV+0BTtlUEnwNF0ftHYWXRhK9ekZNprkZ/YwVgtq9PQ== X-Received: by 2002:ac8:764a:: with SMTP id i10mr13050420qtr.206.1633096005753; Fri, 01 Oct 2021 06:46:45 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id i11sm2763429qki.28.2021.10.01.06.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 06:46:45 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] Date: Fri, 1 Oct 2021 09:46:43 -0400 Message-Id: <20211001134643.1941700-1-ppalka@redhat.com> X-Mailer: git-send-email 2.33.0.610.gcefe983a32 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Patrick Palka via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Patrick Palka <ppalka@redhat.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]
|
|
Commit Message
Patrick Palka
Oct. 1, 2021, 1:46 p.m. UTC
Here during partial ordering of the two partial specializations we end up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly thereafter because uses_template_parms calls potential_constant_expression which doesn't handle NONTYPE_ARGUMENT_PACK. This patch fixes this by checking dependent_template_arg_p instead of uses_template_parms when parm==arg, which does handle NONTYPE_ARGUMENT_PACK. We could also perhaps fix uses_template_parms / inst_dep_expr_p to better handle NONTYPE_ARGUMENT_PACK, but interestingly none of our existing tests exercise calling those functions on NONTYPE_ARGUMENT_PACK, so such a fix would be seemingly moot. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? PR c++/102547 gcc/cp/ChangeLog: * pt.c (unify): Check dependent_template_arg_p instead of uses_template_parms when parm==arg. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-partial2.C: New test. --- gcc/cp/pt.c | 2 +- .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C
Comments
On 10/1/21 09:46, Patrick Palka wrote: > Here during partial ordering of the two partial specializations we end > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly > thereafter because uses_template_parms calls potential_constant_expression > which doesn't handle NONTYPE_ARGUMENT_PACK. > > This patch fixes this by checking dependent_template_arg_p instead of > uses_template_parms when parm==arg, which does handle NONTYPE_ARGUMENT_PACK. > We could also perhaps fix uses_template_parms / inst_dep_expr_p to better > handle NONTYPE_ARGUMENT_PACK, Please. > but interestingly none of our existing tests > exercise calling those functions on NONTYPE_ARGUMENT_PACK, so such a fix > would be seemingly moot. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/11? > > PR c++/102547 > > gcc/cp/ChangeLog: > > * pt.c (unify): Check dependent_template_arg_p instead of > uses_template_parms when parm==arg. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/variadic-partial2.C: New test. > --- > gcc/cp/pt.c | 2 +- > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > 3 files changed, 39 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > index 1dcdffe322a..59c00c77a30 100644 > --- a/gcc/cp/pt.c > +++ b/gcc/cp/pt.c > @@ -23587,7 +23587,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, > even if ARG == PARM, since we won't record unifications for the > template parameters. We might need them if we're trying to > figure out which of two things is more specialized. */ > - if (arg == parm && !uses_template_parms (parm)) > + if (arg == parm && !dependent_template_arg_p (parm)) > return unify_success (explain_p); > > /* Handle init lists early, so the rest of the function can assume > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > new file mode 100644 > index 00000000000..df61f26a3c1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > @@ -0,0 +1,16 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +struct vals_client { }; > + > +template<int V0, int V1, class T> > +struct vals_client<vals<V0, V1>, T> { }; > + > +template<int V0, int V1> > +struct vals_client<vals<V0, V1>, void> { }; > + > +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > new file mode 100644 > index 00000000000..cc0ea488ad3 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > @@ -0,0 +1,22 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > +// A version of variadic-partial2.C where the partial ordering is performed > +// on function templates instead of class templates. > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +void f(V, T) { }; > + > +template<int V0, int V1, class T> > +void f(vals<V0, V1>, T) { }; > + > +template<int V0, int V1> > +void f(vals<V0, V1>, char) { }; > + > +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" > + > +int main() { > + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" > +} >
On Fri, 1 Oct 2021, Jason Merrill wrote: > On 10/1/21 09:46, Patrick Palka wrote: > > Here during partial ordering of the two partial specializations we end > > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly > > thereafter because uses_template_parms calls potential_constant_expression > > which doesn't handle NONTYPE_ARGUMENT_PACK. > > > > This patch fixes this by checking dependent_template_arg_p instead of > > uses_template_parms when parm==arg, which does handle NONTYPE_ARGUMENT_PACK. > > We could also perhaps fix uses_template_parms / inst_dep_expr_p to better > > handle NONTYPE_ARGUMENT_PACK, > > Please. Sounds good, like the following then? Passes light testing, bootstrap and regtest on progress. -- >8 -- PR c++/102547 gcc/cp/ChangeLog: * pt.c (instantiation_dependent_expression_p): Sidestep checking potential_constant_expression on NONTYPE_ARGUMENT_PACK. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-partial2.C: New test. * g++.dg/cpp0x/variadic-partial2a.C: New test. --- gcc/cp/pt.c | 4 +++- .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1dcdffe322a..643204103c5 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree expression) { return (instantiation_dependent_uneval_expression_p (expression) || (processing_template_decl - && potential_constant_expression (expression) + && expression != NULL_TREE + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK + || potential_constant_expression (expression)) && value_dependent_expression_p (expression))); } diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C new file mode 100644 index 00000000000..df61f26a3c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C @@ -0,0 +1,16 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } + +template<int... Vs> +struct vals { }; + +template<class V, class T> +struct vals_client { }; + +template<int V0, int V1, class T> +struct vals_client<vals<V0, V1>, T> { }; + +template<int V0, int V1> +struct vals_client<vals<V0, V1>, void> { }; + +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C new file mode 100644 index 00000000000..cc0ea488ad3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C @@ -0,0 +1,22 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } +// A version of variadic-partial2.C where the partial ordering is performed +// on function templates instead of class templates. + +template<int... Vs> +struct vals { }; + +template<class V, class T> +void f(V, T) { }; + +template<int V0, int V1, class T> +void f(vals<V0, V1>, T) { }; + +template<int V0, int V1> +void f(vals<V0, V1>, char) { }; + +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" + +int main() { + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" +}
On 10/1/21 10:26, Patrick Palka wrote: > On Fri, 1 Oct 2021, Jason Merrill wrote: > >> On 10/1/21 09:46, Patrick Palka wrote: >>> Here during partial ordering of the two partial specializations we end >>> up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly >>> thereafter because uses_template_parms calls potential_constant_expression >>> which doesn't handle NONTYPE_ARGUMENT_PACK. >>> >>> This patch fixes this by checking dependent_template_arg_p instead of >>> uses_template_parms when parm==arg, which does handle NONTYPE_ARGUMENT_PACK. >>> We could also perhaps fix uses_template_parms / inst_dep_expr_p to better >>> handle NONTYPE_ARGUMENT_PACK, >> >> Please. > > Sounds good, like the following then? Passes light testing, bootstrap > and regtest on progress. > > -- >8 -- > > PR c++/102547 > > gcc/cp/ChangeLog: > > * pt.c (instantiation_dependent_expression_p): Sidestep checking > potential_constant_expression on NONTYPE_ARGUMENT_PACK. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/variadic-partial2.C: New test. > * g++.dg/cpp0x/variadic-partial2a.C: New test. > --- > gcc/cp/pt.c | 4 +++- > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > 3 files changed, 41 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > index 1dcdffe322a..643204103c5 100644 > --- a/gcc/cp/pt.c > +++ b/gcc/cp/pt.c > @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree expression) > { > return (instantiation_dependent_uneval_expression_p (expression) > || (processing_template_decl > - && potential_constant_expression (expression) > + && expression != NULL_TREE > + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK > + || potential_constant_expression (expression)) I'd prefer to loop over the elements of the pack, either here or (probably better) in potential_constant_expression. > && value_dependent_expression_p (expression))); > } > > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > new file mode 100644 > index 00000000000..df61f26a3c1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > @@ -0,0 +1,16 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +struct vals_client { }; > + > +template<int V0, int V1, class T> > +struct vals_client<vals<V0, V1>, T> { }; > + > +template<int V0, int V1> > +struct vals_client<vals<V0, V1>, void> { }; > + > +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > new file mode 100644 > index 00000000000..cc0ea488ad3 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > @@ -0,0 +1,22 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > +// A version of variadic-partial2.C where the partial ordering is performed > +// on function templates instead of class templates. > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +void f(V, T) { }; > + > +template<int V0, int V1, class T> > +void f(vals<V0, V1>, T) { }; > + > +template<int V0, int V1> > +void f(vals<V0, V1>, char) { }; > + > +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" > + > +int main() { > + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" > +} >
On Fri, 1 Oct 2021, Jason Merrill wrote: > On 10/1/21 10:26, Patrick Palka wrote: > > On Fri, 1 Oct 2021, Jason Merrill wrote: > > > > > On 10/1/21 09:46, Patrick Palka wrote: > > > > Here during partial ordering of the two partial specializations we end > > > > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash > > > > shortly > > > > thereafter because uses_template_parms calls > > > > potential_constant_expression > > > > which doesn't handle NONTYPE_ARGUMENT_PACK. > > > > > > > > This patch fixes this by checking dependent_template_arg_p instead of > > > > uses_template_parms when parm==arg, which does handle > > > > NONTYPE_ARGUMENT_PACK. > > > > We could also perhaps fix uses_template_parms / inst_dep_expr_p to > > > > better > > > > handle NONTYPE_ARGUMENT_PACK, > > > > > > Please. > > > > Sounds good, like the following then? Passes light testing, bootstrap > > and regtest on progress. > > > > -- >8 -- > > > > PR c++/102547 > > > > gcc/cp/ChangeLog: > > > > * pt.c (instantiation_dependent_expression_p): Sidestep checking > > potential_constant_expression on NONTYPE_ARGUMENT_PACK. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/cpp0x/variadic-partial2.C: New test. > > * g++.dg/cpp0x/variadic-partial2a.C: New test. > > --- > > gcc/cp/pt.c | 4 +++- > > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > > 3 files changed, 41 insertions(+), 1 deletion(-) > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > > index 1dcdffe322a..643204103c5 100644 > > --- a/gcc/cp/pt.c > > +++ b/gcc/cp/pt.c > > @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree > > expression) > > { > > return (instantiation_dependent_uneval_expression_p (expression) > > || (processing_template_decl > > - && potential_constant_expression (expression) > > + && expression != NULL_TREE > > + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK > > + || potential_constant_expression (expression)) > > I'd prefer to loop over the elements of the pack, either here or (probably > better) in potential_constant_expression. Ah, makes sense. Like so? Bootstrapped and regtested on x86_64-pc-linux-gnu. -- >8 -- Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] Here during partial ordering of the two partial specializations we end up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly thereafter because uses_template_parms(parms) calls potential_const_expr which doesn't handle NONTYPE_ARGUMENT_PACK. This patch fixes this by extending potential_constant_expression to handle NONTYPE_ARGUMENT_PACK appropriately. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? PR c++/102547 gcc/cp/ChangeLog: * constexpr.c (potential_constant_expression_1): Handle NONTYPE_ARGUMENT_PACK. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-partial2.C: New test. * g++.dg/cpp0x/variadic-partial2a.C: New test. --- gcc/cp/constexpr.c | 10 +++++++++ .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 18d9d117a48..e95ff00774f 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -9043,6 +9043,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, case CO_RETURN_EXPR: return false; + case NONTYPE_ARGUMENT_PACK: + { + tree args = ARGUMENT_PACK_ARGS (t); + int len = TREE_VEC_LENGTH (args); + for (int i = 0; i < len; ++i) + if (!RECUR (TREE_VEC_ELT (args, i), any)) + return false; + return true; + } + default: if (objc_non_constant_expr_p (t)) return false; diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C new file mode 100644 index 00000000000..df61f26a3c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C @@ -0,0 +1,16 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } + +template<int... Vs> +struct vals { }; + +template<class V, class T> +struct vals_client { }; + +template<int V0, int V1, class T> +struct vals_client<vals<V0, V1>, T> { }; + +template<int V0, int V1> +struct vals_client<vals<V0, V1>, void> { }; + +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C new file mode 100644 index 00000000000..e98bdbbc07b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C @@ -0,0 +1,22 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } +// A version of variadic-partial2.C where partial ordering is performed +// on function templates instead of class templates. + +template<int... Vs> +struct vals { }; + +template<class V, class T> +void f(V, T) { }; + +template<int V0, int V1, class T> +void f(vals<V0, V1>, T) { }; + +template<int V0, int V1> +void f(vals<V0, V1>, char) { }; + +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" + +int main() { + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" +}
On Fri, Oct 1, 2021 at 1:29 PM Patrick Palka <ppalka@redhat.com> wrote: > > On Fri, 1 Oct 2021, Jason Merrill wrote: > > > On 10/1/21 10:26, Patrick Palka wrote: > > > On Fri, 1 Oct 2021, Jason Merrill wrote: > > > > > > > On 10/1/21 09:46, Patrick Palka wrote: > > > > > Here during partial ordering of the two partial specializations we end > > > > > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash > > > > > shortly > > > > > thereafter because uses_template_parms calls > > > > > potential_constant_expression > > > > > which doesn't handle NONTYPE_ARGUMENT_PACK. > > > > > > > > > > This patch fixes this by checking dependent_template_arg_p instead of > > > > > uses_template_parms when parm==arg, which does handle > > > > > NONTYPE_ARGUMENT_PACK. > > > > > We could also perhaps fix uses_template_parms / inst_dep_expr_p to > > > > > better > > > > > handle NONTYPE_ARGUMENT_PACK, > > > > > > > > Please. > > > > > > Sounds good, like the following then? Passes light testing, bootstrap > > > and regtest on progress. > > > > > > -- >8 -- > > > > > > PR c++/102547 > > > > > > gcc/cp/ChangeLog: > > > > > > * pt.c (instantiation_dependent_expression_p): Sidestep checking > > > potential_constant_expression on NONTYPE_ARGUMENT_PACK. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * g++.dg/cpp0x/variadic-partial2.C: New test. > > > * g++.dg/cpp0x/variadic-partial2a.C: New test. > > > --- > > > gcc/cp/pt.c | 4 +++- > > > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > > > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > > > > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > > > index 1dcdffe322a..643204103c5 100644 > > > --- a/gcc/cp/pt.c > > > +++ b/gcc/cp/pt.c > > > @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree > > > expression) > > > { > > > return (instantiation_dependent_uneval_expression_p (expression) > > > || (processing_template_decl > > > - && potential_constant_expression (expression) > > > + && expression != NULL_TREE > > > + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK > > > + || potential_constant_expression (expression)) > > > > I'd prefer to loop over the elements of the pack, either here or (probably > > better) in potential_constant_expression. > > Ah, makes sense. Like so? Bootstrapped and regtested on > x86_64-pc-linux-gnu. On second thought given that a NONTYPE_ARGUMENT_PACK is by construction a sequence of non-type template arguments, is looping over its elements in potential_const_expr necessary? Maybe we should just return true unconditionally. > > -- >8 -- > > Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] > > Here during partial ordering of the two partial specializations we end > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly > thereafter because uses_template_parms(parms) calls potential_const_expr > which doesn't handle NONTYPE_ARGUMENT_PACK. > > This patch fixes this by extending potential_constant_expression to handle > NONTYPE_ARGUMENT_PACK appropriately. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/11? > > PR c++/102547 > > gcc/cp/ChangeLog: > > * constexpr.c (potential_constant_expression_1): Handle > NONTYPE_ARGUMENT_PACK. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/variadic-partial2.C: New test. > * g++.dg/cpp0x/variadic-partial2a.C: New test. > --- > gcc/cp/constexpr.c | 10 +++++++++ > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > 3 files changed, 48 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c > index 18d9d117a48..e95ff00774f 100644 > --- a/gcc/cp/constexpr.c > +++ b/gcc/cp/constexpr.c > @@ -9043,6 +9043,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > case CO_RETURN_EXPR: > return false; > > + case NONTYPE_ARGUMENT_PACK: > + { > + tree args = ARGUMENT_PACK_ARGS (t); > + int len = TREE_VEC_LENGTH (args); > + for (int i = 0; i < len; ++i) > + if (!RECUR (TREE_VEC_ELT (args, i), any)) > + return false; > + return true; > + } > + > default: > if (objc_non_constant_expr_p (t)) > return false; > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > new file mode 100644 > index 00000000000..df61f26a3c1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > @@ -0,0 +1,16 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +struct vals_client { }; > + > +template<int V0, int V1, class T> > +struct vals_client<vals<V0, V1>, T> { }; > + > +template<int V0, int V1> > +struct vals_client<vals<V0, V1>, void> { }; > + > +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > new file mode 100644 > index 00000000000..e98bdbbc07b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > @@ -0,0 +1,22 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > +// A version of variadic-partial2.C where partial ordering is performed > +// on function templates instead of class templates. > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +void f(V, T) { }; > + > +template<int V0, int V1, class T> > +void f(vals<V0, V1>, T) { }; > + > +template<int V0, int V1> > +void f(vals<V0, V1>, char) { }; > + > +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" > + > +int main() { > + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" > +} > -- > 2.33.0.610.gcefe983a32 >
On Fri, 1 Oct 2021, Patrick Palka wrote: > On Fri, Oct 1, 2021 at 1:29 PM Patrick Palka <ppalka@redhat.com> wrote: > > > > On Fri, 1 Oct 2021, Jason Merrill wrote: > > > > > On 10/1/21 10:26, Patrick Palka wrote: > > > > On Fri, 1 Oct 2021, Jason Merrill wrote: > > > > > > > > > On 10/1/21 09:46, Patrick Palka wrote: > > > > > > Here during partial ordering of the two partial specializations we end > > > > > > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash > > > > > > shortly > > > > > > thereafter because uses_template_parms calls > > > > > > potential_constant_expression > > > > > > which doesn't handle NONTYPE_ARGUMENT_PACK. > > > > > > > > > > > > This patch fixes this by checking dependent_template_arg_p instead of > > > > > > uses_template_parms when parm==arg, which does handle > > > > > > NONTYPE_ARGUMENT_PACK. > > > > > > We could also perhaps fix uses_template_parms / inst_dep_expr_p to > > > > > > better > > > > > > handle NONTYPE_ARGUMENT_PACK, > > > > > > > > > > Please. > > > > > > > > Sounds good, like the following then? Passes light testing, bootstrap > > > > and regtest on progress. > > > > > > > > -- >8 -- > > > > > > > > PR c++/102547 > > > > > > > > gcc/cp/ChangeLog: > > > > > > > > * pt.c (instantiation_dependent_expression_p): Sidestep checking > > > > potential_constant_expression on NONTYPE_ARGUMENT_PACK. > > > > > > > > gcc/testsuite/ChangeLog: > > > > > > > > * g++.dg/cpp0x/variadic-partial2.C: New test. > > > > * g++.dg/cpp0x/variadic-partial2a.C: New test. > > > > --- > > > > gcc/cp/pt.c | 4 +++- > > > > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > > > > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > > > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > > > > > > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c > > > > index 1dcdffe322a..643204103c5 100644 > > > > --- a/gcc/cp/pt.c > > > > +++ b/gcc/cp/pt.c > > > > @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree > > > > expression) > > > > { > > > > return (instantiation_dependent_uneval_expression_p (expression) > > > > || (processing_template_decl > > > > - && potential_constant_expression (expression) > > > > + && expression != NULL_TREE > > > > + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK > > > > + || potential_constant_expression (expression)) > > > > > > I'd prefer to loop over the elements of the pack, either here or (probably > > > better) in potential_constant_expression. > > > > Ah, makes sense. Like so? Bootstrapped and regtested on > > x86_64-pc-linux-gnu. > > On second thought given that a NONTYPE_ARGUMENT_PACK is by > construction a sequence of non-type template arguments, is looping > over its elements in potential_const_expr necessary? Maybe we should > just return true unconditionally. Never mind, I forgot that we also use NONTYPE_ARGUMENT_PACK to pack function arguments, so we can't just assume the elements are always constant. > > > > > -- >8 -- > > > > Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] > > > > Here during partial ordering of the two partial specializations we end > > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly > > thereafter because uses_template_parms(parms) calls potential_const_expr > > which doesn't handle NONTYPE_ARGUMENT_PACK. > > > > This patch fixes this by extending potential_constant_expression to handle > > NONTYPE_ARGUMENT_PACK appropriately. > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > > trunk/11? > > > > PR c++/102547 > > > > gcc/cp/ChangeLog: > > > > * constexpr.c (potential_constant_expression_1): Handle > > NONTYPE_ARGUMENT_PACK. > > > > gcc/testsuite/ChangeLog: > > > > * g++.dg/cpp0x/variadic-partial2.C: New test. > > * g++.dg/cpp0x/variadic-partial2a.C: New test. > > --- > > gcc/cp/constexpr.c | 10 +++++++++ > > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > > 3 files changed, 48 insertions(+) > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > > > diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c > > index 18d9d117a48..e95ff00774f 100644 > > --- a/gcc/cp/constexpr.c > > +++ b/gcc/cp/constexpr.c > > @@ -9043,6 +9043,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > > case CO_RETURN_EXPR: > > return false; > > > > + case NONTYPE_ARGUMENT_PACK: > > + { > > + tree args = ARGUMENT_PACK_ARGS (t); > > + int len = TREE_VEC_LENGTH (args); > > + for (int i = 0; i < len; ++i) > > + if (!RECUR (TREE_VEC_ELT (args, i), any)) > > + return false; > > + return true; > > + } > > + > > default: > > if (objc_non_constant_expr_p (t)) > > return false; > > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > new file mode 100644 > > index 00000000000..df61f26a3c1 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > > @@ -0,0 +1,16 @@ > > +// PR c++/102547 > > +// { dg-do compile { target c++11 } } > > + > > +template<int... Vs> > > +struct vals { }; > > + > > +template<class V, class T> > > +struct vals_client { }; > > + > > +template<int V0, int V1, class T> > > +struct vals_client<vals<V0, V1>, T> { }; > > + > > +template<int V0, int V1> > > +struct vals_client<vals<V0, V1>, void> { }; > > + > > +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" > > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > new file mode 100644 > > index 00000000000..e98bdbbc07b > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > @@ -0,0 +1,22 @@ > > +// PR c++/102547 > > +// { dg-do compile { target c++11 } } > > +// A version of variadic-partial2.C where partial ordering is performed > > +// on function templates instead of class templates. > > + > > +template<int... Vs> > > +struct vals { }; > > + > > +template<class V, class T> > > +void f(V, T) { }; > > + > > +template<int V0, int V1, class T> > > +void f(vals<V0, V1>, T) { }; > > + > > +template<int V0, int V1> > > +void f(vals<V0, V1>, char) { }; > > + > > +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" > > + > > +int main() { > > + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" > > +} > > -- > > 2.33.0.610.gcefe983a32 > > >
On 10/1/21 13:29, Patrick Palka wrote: > On Fri, 1 Oct 2021, Jason Merrill wrote: > >> On 10/1/21 10:26, Patrick Palka wrote: >>> On Fri, 1 Oct 2021, Jason Merrill wrote: >>> >>>> On 10/1/21 09:46, Patrick Palka wrote: >>>>> Here during partial ordering of the two partial specializations we end >>>>> up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash >>>>> shortly >>>>> thereafter because uses_template_parms calls >>>>> potential_constant_expression >>>>> which doesn't handle NONTYPE_ARGUMENT_PACK. >>>>> >>>>> This patch fixes this by checking dependent_template_arg_p instead of >>>>> uses_template_parms when parm==arg, which does handle >>>>> NONTYPE_ARGUMENT_PACK. >>>>> We could also perhaps fix uses_template_parms / inst_dep_expr_p to >>>>> better >>>>> handle NONTYPE_ARGUMENT_PACK, >>>> >>>> Please. >>> >>> Sounds good, like the following then? Passes light testing, bootstrap >>> and regtest on progress. >>> >>> -- >8 -- >>> >>> PR c++/102547 >>> >>> gcc/cp/ChangeLog: >>> >>> * pt.c (instantiation_dependent_expression_p): Sidestep checking >>> potential_constant_expression on NONTYPE_ARGUMENT_PACK. >>> >>> gcc/testsuite/ChangeLog: >>> >>> * g++.dg/cpp0x/variadic-partial2.C: New test. >>> * g++.dg/cpp0x/variadic-partial2a.C: New test. >>> --- >>> gcc/cp/pt.c | 4 +++- >>> .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ >>> .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ >>> 3 files changed, 41 insertions(+), 1 deletion(-) >>> create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C >>> create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C >>> >>> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c >>> index 1dcdffe322a..643204103c5 100644 >>> --- a/gcc/cp/pt.c >>> +++ b/gcc/cp/pt.c >>> @@ -27705,7 +27705,9 @@ instantiation_dependent_expression_p (tree >>> expression) >>> { >>> return (instantiation_dependent_uneval_expression_p (expression) >>> || (processing_template_decl >>> - && potential_constant_expression (expression) >>> + && expression != NULL_TREE >>> + && (TREE_CODE (expression) == NONTYPE_ARGUMENT_PACK >>> + || potential_constant_expression (expression)) >> >> I'd prefer to loop over the elements of the pack, either here or (probably >> better) in potential_constant_expression. > > Ah, makes sense. Like so? Bootstrapped and regtested on > x86_64-pc-linux-gnu. > > -- >8 -- > > Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] > > Here during partial ordering of the two partial specializations we end > up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly > thereafter because uses_template_parms(parms) calls potential_const_expr > which doesn't handle NONTYPE_ARGUMENT_PACK. > > This patch fixes this by extending potential_constant_expression to handle > NONTYPE_ARGUMENT_PACK appropriately. > > Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for > trunk/11? OK. > PR c++/102547 > > gcc/cp/ChangeLog: > > * constexpr.c (potential_constant_expression_1): Handle > NONTYPE_ARGUMENT_PACK. > > gcc/testsuite/ChangeLog: > > * g++.dg/cpp0x/variadic-partial2.C: New test. > * g++.dg/cpp0x/variadic-partial2a.C: New test. > --- > gcc/cp/constexpr.c | 10 +++++++++ > .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ > .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ > 3 files changed, 48 insertions(+) > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > > diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c > index 18d9d117a48..e95ff00774f 100644 > --- a/gcc/cp/constexpr.c > +++ b/gcc/cp/constexpr.c > @@ -9043,6 +9043,16 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, > case CO_RETURN_EXPR: > return false; > > + case NONTYPE_ARGUMENT_PACK: > + { > + tree args = ARGUMENT_PACK_ARGS (t); > + int len = TREE_VEC_LENGTH (args); > + for (int i = 0; i < len; ++i) > + if (!RECUR (TREE_VEC_ELT (args, i), any)) > + return false; > + return true; > + } > + > default: > if (objc_non_constant_expr_p (t)) > return false; > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > new file mode 100644 > index 00000000000..df61f26a3c1 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C > @@ -0,0 +1,16 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +struct vals_client { }; > + > +template<int V0, int V1, class T> > +struct vals_client<vals<V0, V1>, T> { }; > + > +template<int V0, int V1> > +struct vals_client<vals<V0, V1>, void> { }; > + > +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" > diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > new file mode 100644 > index 00000000000..e98bdbbc07b > --- /dev/null > +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C > @@ -0,0 +1,22 @@ > +// PR c++/102547 > +// { dg-do compile { target c++11 } } > +// A version of variadic-partial2.C where partial ordering is performed > +// on function templates instead of class templates. > + > +template<int... Vs> > +struct vals { }; > + > +template<class V, class T> > +void f(V, T) { }; > + > +template<int V0, int V1, class T> > +void f(vals<V0, V1>, T) { }; > + > +template<int V0, int V1> > +void f(vals<V0, V1>, char) { }; > + > +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" > + > +int main() { > + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" > +} >
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1dcdffe322a..59c00c77a30 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23587,7 +23587,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, even if ARG == PARM, since we won't record unifications for the template parameters. We might need them if we're trying to figure out which of two things is more specialized. */ - if (arg == parm && !uses_template_parms (parm)) + if (arg == parm && !dependent_template_arg_p (parm)) return unify_success (explain_p); /* Handle init lists early, so the rest of the function can assume diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C new file mode 100644 index 00000000000..df61f26a3c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C @@ -0,0 +1,16 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } + +template<int... Vs> +struct vals { }; + +template<class V, class T> +struct vals_client { }; + +template<int V0, int V1, class T> +struct vals_client<vals<V0, V1>, T> { }; + +template<int V0, int V1> +struct vals_client<vals<V0, V1>, void> { }; + +template struct vals_client<vals<1, 2>, void>; //- "sorry, unimplemented..., ICE" diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C new file mode 100644 index 00000000000..cc0ea488ad3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C @@ -0,0 +1,22 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } +// A version of variadic-partial2.C where the partial ordering is performed +// on function templates instead of class templates. + +template<int... Vs> +struct vals { }; + +template<class V, class T> +void f(V, T) { }; + +template<int V0, int V1, class T> +void f(vals<V0, V1>, T) { }; + +template<int V0, int V1> +void f(vals<V0, V1>, char) { }; + +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" + +int main() { + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" +}