diff mbox series

[pushed] c++: Fix template parm with dependent type in concepts.

Message ID 20200324222452.8444-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: Fix template parm with dependent type in concepts. | expand

Commit Message

Li, Pan2 via Gcc-patches March 24, 2020, 10:24 p.m. UTC
While looking at PR94186 I also noticed this regression; if a non-type
template parameter uses a type parameter in its type, we need to map both
template parameters.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/cp/ChangeLog
2020-03-24  Jason Merrill  <jason@redhat.com>

	* pt.c (any_template_parm_r): Look into the type of a non-type
	template parm.
---
 gcc/cp/pt.c                                    |  1 +
 gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C | 11 +++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C


base-commit: 07f8bcc6ea9f3c0850a56a7431d866178d5cee92
diff mbox series

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 03a8dfbd37c..3c96eeca191 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10431,6 +10431,7 @@  any_template_parm_r (tree t, void *data)
       WALK_SUBTREE (TREE_OPERAND (t, 1));
       break;
 
+    case TEMPLATE_PARM_INDEX:
     case PARM_DECL:
       /* A parameter or constraint variable may also depend on a template
 	 parameter without explicitly naming it.  */
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C b/gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C
new file mode 100644
index 00000000000..ebede46b368
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C
@@ -0,0 +1,11 @@ 
+// { dg-do compile { target concepts } }
+
+template<class X, X x>
+concept C = requires {
+    requires x;			// { dg-error "bool" }
+  };
+
+int main() {
+  C<int, 0>;
+  return 0;
+}