aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-05-29 16:55:52 -0400
committerJason Merrill <jason@redhat.com>2020-05-29 18:16:54 -0400
commit2fb595f8348e164d2f06536ba98322616eeaeeb6 (patch)
tree62f985a6ba84d868d4e1829dd6f69b38054c4840 /gcc
parent33e23881aae0549572cc23a2520c5094a2ffede9 (diff)
downloadgcc-2fb595f8348e164d2f06536ba98322616eeaeeb6.zip
gcc-2fb595f8348e164d2f06536ba98322616eeaeeb6.tar.gz
gcc-2fb595f8348e164d2f06536ba98322616eeaeeb6.tar.bz2
c++: Template template parameter in constraint [PR95371]
any_template_parm_r was assuming that the DECL_TEMPLATE_RESULT of a template will have a suitable TEMPLATE_INFO from which we can look at the generic arguments for that template. But that wasn't true for a template template parameter; this patch makes it so. gcc/cp/ChangeLog: PR c++/95371 * pt.c (process_template_parm): Set DECL_TEMPLATE_INFO on the DECL_TEMPLATE_RESULT. gcc/testsuite/ChangeLog: PR c++/95371 * g++.dg/cpp2a/concepts-ttp1.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.c11
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/concepts-ttp1.C16
2 files changed, 26 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 90dafff..df647af 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4575,7 +4575,16 @@ process_template_parm (tree list, location_t parm_loc, tree parm,
/* This is for distinguishing between real templates and template
template parameters */
TREE_TYPE (parm) = t;
- TREE_TYPE (DECL_TEMPLATE_RESULT (parm)) = t;
+
+ /* any_template_parm_r expects to be able to get the targs of a
+ DECL_TEMPLATE_RESULT. */
+ tree result = DECL_TEMPLATE_RESULT (parm);
+ TREE_TYPE (result) = t;
+ tree args = template_parms_to_args (DECL_TEMPLATE_PARMS (parm));
+ tree tinfo = build_template_info (parm, args);
+ retrofit_lang_decl (result);
+ DECL_TEMPLATE_INFO (result) = tinfo;
+
decl = parm;
}
else
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp1.C
new file mode 100644
index 0000000..3f6eb35
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp1.C
@@ -0,0 +1,16 @@
+// PR c++/95371
+// { dg-do compile { target c++20 } }
+
+template <typename...>
+struct configuration {
+ template <template <typename...> typename query_t>
+ static constexpr bool exists() { return true; }
+
+ template <template <typename...> typename query_t>
+ void remove() requires(exists<query_t>());
+};
+
+int main() {
+ configuration<> cfg{};
+ cfg.remove<configuration>();
+}