From 2befd3f722b21e47f238c61400955eb9e65ce782 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 21 Jun 2016 14:19:13 -0400 Subject: [PATCH] Fix constraint satisfaction in uninstantiated template. * constraint.cc (constraints_satisfied_p): Keep as many levels of args as our template has levels of parms. From-SVN: r237655 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/constraint.cc | 6 ++++-- gcc/testsuite/g++.dg/concepts/memtmpl1.C | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/concepts/memtmpl1.C 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 + * 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 +struct A { + template + requires sizeof(T) == 1 + static void f(U); + template + requires sizeof(T) == 2 + static void f(U); + void g() + { + f(42); + } +}; -- 2.30.2