summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-21 18:19:13 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-21 18:19:13 +0000
commit61e0c726e04313042831610ce72c2eaa841af18a (patch)
treeb2ca415533cd375bcd773bd499901ff83b30da51
parent88b05face78bb623f28890a2d6caf3b5e7836650 (diff)
downloadgcc-61e0c726e04313042831610ce72c2eaa841af18a.tar.gz
Fix constraint satisfaction in uninstantiated template.
* constraint.cc (constraints_satisfied_p): Keep as many levels of args as our template has levels of parms. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237655 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/constraint.cc6
-rw-r--r--gcc/testsuite/g++.dg/concepts/memtmpl1.C15
3 files changed, 22 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c8aa71360e2..20e34d677ee 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2016-06-21 Jason Merrill <jason@redhat.com>
+ * constraint.cc (constraints_satisfied_p): Keep as many levels of
+ args as our template has levels of parms.
+
* pt.c (template_parm_outer_level, uses_outer_template_parms): New.
(type_dependent_expression_p): Use uses_outer_template_parms.
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 5e42fa90104..af7a593a4f6 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2122,8 +2122,10 @@ constraints_satisfied_p (tree decl)
tree args = NULL_TREE;
if (tree ti = DECL_TEMPLATE_INFO (decl))
{
- ci = get_constraints (TI_TEMPLATE (ti));
- args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (ti));
+ tree tmpl = TI_TEMPLATE (ti);
+ ci = get_constraints (tmpl);
+ int depth = TMPL_PARMS_DEPTH (DECL_TEMPLATE_PARMS (tmpl));
+ args = get_innermost_template_args (TI_ARGS (ti), depth);
}
else
{
diff --git a/gcc/testsuite/g++.dg/concepts/memtmpl1.C b/gcc/testsuite/g++.dg/concepts/memtmpl1.C
new file mode 100644
index 00000000000..6f3d5a3ebf6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/memtmpl1.C
@@ -0,0 +1,15 @@
+// { dg-options "-std=c++1z -fconcepts" }
+
+template <class T>
+struct A {
+ template <class U>
+ requires sizeof(T) == 1
+ static void f(U);
+ template <class U>
+ requires sizeof(T) == 2
+ static void f(U);
+ void g()
+ {
+ f(42);
+ }
+};