public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-4196] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]
Date: Tue,  5 Oct 2021 19:36:35 +0000 (GMT)	[thread overview]
Message-ID: <20211005193635.5CDA3385802D@sourceware.org> (raw)

https://gcc.gnu.org/g:d4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d

commit r12-4196-gd4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Oct 5 15:35:21 2021 -0400

    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.
    
            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.

Diff:
---
 gcc/cp/constexpr.c                              | 10 ++++++++++
 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C  | 16 ++++++++++++++++
 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C | 22 ++++++++++++++++++++++
 3 files changed, 48 insertions(+)

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"
+}


                 reply	other threads:[~2021-10-05 19:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211005193635.5CDA3385802D@sourceware.org \
    --to=ppalka@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).