* [PATCH] c++: reject concept w/ multiple tparm lists [PR105067]
@ 2022-03-28 13:28 Patrick Palka
2022-03-28 17:31 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-03-28 13:28 UTC (permalink / raw)
To: gcc-patches
We weren't rejecting a concept declared with multiple template
parameter lists.
Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk?
PR c++/105067
gcc/cp/ChangeLog:
* pt.cc (finish_concept_definition): Require that a concept is
declared with exactly one template parameter list.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-err4.C: New test.
---
gcc/cp/pt.cc | 6 ++++++
gcc/testsuite/g++.dg/cpp2a/concepts-err4.C | 6 ++++++
2 files changed, 12 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 173bc3a8c7f..bd937499934 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -28775,6 +28775,12 @@ finish_concept_definition (cp_expr id, tree init)
return error_mark_node;
}
+ if (current_template_depth > 1)
+ {
+ error_at (loc, "concept %qE has multiple template parameter lists", *id);
+ return error_mark_node;
+ }
+
/* Initially build the concept declaration; its type is bool. */
tree decl = build_lang_decl_loc (loc, CONCEPT_DECL, *id, boolean_type_node);
DECL_CONTEXT (decl) = current_scope ();
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
new file mode 100644
index 00000000000..57a96a095c7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
@@ -0,0 +1,6 @@
+// PR c++/105067
+// { dg-do compile { target c++20 } }
+
+template<class>
+template<class>
+concept C = true; // { dg-error "parameter list" }
--
2.35.1.677.gabf474a5dd
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] c++: reject concept w/ multiple tparm lists [PR105067]
2022-03-28 13:28 [PATCH] c++: reject concept w/ multiple tparm lists [PR105067] Patrick Palka
@ 2022-03-28 17:31 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2022-03-28 17:31 UTC (permalink / raw)
To: Patrick Palka, gcc-patches
On 3/28/22 09:28, Patrick Palka wrote:
> We weren't rejecting a concept declared with multiple template
> parameter lists.
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk?
OK.
> PR c++/105067
>
> gcc/cp/ChangeLog:
>
> * pt.cc (finish_concept_definition): Require that a concept is
> declared with exactly one template parameter list.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/cpp2a/concepts-err4.C: New test.
> ---
> gcc/cp/pt.cc | 6 ++++++
> gcc/testsuite/g++.dg/cpp2a/concepts-err4.C | 6 ++++++
> 2 files changed, 12 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index 173bc3a8c7f..bd937499934 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -28775,6 +28775,12 @@ finish_concept_definition (cp_expr id, tree init)
> return error_mark_node;
> }
>
> + if (current_template_depth > 1)
> + {
> + error_at (loc, "concept %qE has multiple template parameter lists", *id);
> + return error_mark_node;
> + }
> +
> /* Initially build the concept declaration; its type is bool. */
> tree decl = build_lang_decl_loc (loc, CONCEPT_DECL, *id, boolean_type_node);
> DECL_CONTEXT (decl) = current_scope ();
> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C b/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
> new file mode 100644
> index 00000000000..57a96a095c7
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-err4.C
> @@ -0,0 +1,6 @@
> +// PR c++/105067
> +// { dg-do compile { target c++20 } }
> +
> +template<class>
> +template<class>
> +concept C = true; // { dg-error "parameter list" }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-28 17:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28 13:28 [PATCH] c++: reject concept w/ multiple tparm lists [PR105067] Patrick Palka
2022-03-28 17:31 ` Jason Merrill
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).