public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] c++: ttp variadic constraint subsumption [PR99904]
Date: Fri,  1 Oct 2021 16:10:22 -0400	[thread overview]
Message-ID: <20211001201022.2678056-1-ppalka@redhat.com> (raw)

Here we're crashing when level-lowering the variadic constraints on the
template template parameter TT because tsubst_pack_expansion expects
processing_template_decl to be set during a partial substitution.

bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk/11?  Also tested on cmcstl2 and range-v3.

	PR c++/99904

gcc/cp/ChangeLog:

	* pt.c (is_compatible_template_arg): Set processing_template_decl
	around tsubst_constraint_info.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-ttp4.C: New test.
---
 gcc/cp/pt.c                                | 2 ++
 gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C | 9 +++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1dcdffe322a..f950f4a21b7 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -8223,8 +8223,10 @@ is_compatible_template_arg (tree parm, tree arg)
     {
       tree aparms = DECL_INNERMOST_TEMPLATE_PARMS (arg);
       new_args = template_parms_level_to_args (aparms);
+      ++processing_template_decl;
       parm_cons = tsubst_constraint_info (parm_cons, new_args,
 					  tf_none, NULL_TREE);
+      --processing_template_decl;
       if (parm_cons == error_mark_node)
         return false;
     }
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C
new file mode 100644
index 00000000000..cf3e71ea974
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp4.C
@@ -0,0 +1,9 @@
+// PR c++/99904
+// { dg-do compile { target c++20 } }
+
+template<class... Ts> concept C = (Ts::value && ...);
+template<class... Ts> requires C<Ts...> struct A;
+template<class T> requires true struct B;
+template<template<class... Ts> requires C<Ts...> class TT> struct S;
+using ty1 = S<A>;
+using ty2 = S<B>; // { dg-error "constraint" } TT's constraints don't subsume B's
-- 
2.33.0.610.gcefe983a32


             reply	other threads:[~2021-10-01 20:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 20:10 Patrick Palka [this message]
2021-10-07  2:17 ` Jason Merrill

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=20211001201022.2678056-1-ppalka@redhat.com \
    --to=ppalka@redhat.com \
    --cc=gcc-patches@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).