aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-03-24 18:25:17 -0400
committerJason Merrill <jason@redhat.com>2020-03-24 18:25:18 -0400
commit5c1617418432466f3f91d282d356bdec91e9dbd2 (patch)
treeaac1fbf15d6cdc9db1491fd3cc0ab70d2ba8e23c
parent6e771c087b10d5b730240ea35478eab8694c9c5d (diff)
downloadgcc-5c1617418432466f3f91d282d356bdec91e9dbd2.zip
gcc-5c1617418432466f3f91d282d356bdec91e9dbd2.tar.gz
gcc-5c1617418432466f3f91d282d356bdec91e9dbd2.tar.bz2
c++: Fix template parm with dependent type in concepts.
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. 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.
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c1
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/concepts-nonbool2.C11
3 files changed, 17 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7ae4128..a4b132d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
2020-03-24 Jason Merrill <jason@redhat.com>
+ * pt.c (any_template_parm_r): Look into the type of a non-type
+ template parm.
+
+2020-03-24 Jason Merrill <jason@redhat.com>
+
* cp-tree.h (cp_expr): When constructing from an expr and a
location, call protected_set_expr_location.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 03a8dfb..3c96eec 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 0000000..ebede46
--- /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;
+}