diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-07-13 14:01:28 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-07-13 14:01:28 -0400 |
commit | f07778f6f92111aa0abfd0f669b148a0bda537a9 (patch) | |
tree | 109eb127acfee6b79ad4f08532b95ffb417f2357 /gcc/cp/constraint.cc | |
parent | f35d65517a59565758107c5b1a51a5fa382f8d1a (diff) | |
download | gcc-f07778f6f92111aa0abfd0f669b148a0bda537a9.zip gcc-f07778f6f92111aa0abfd0f669b148a0bda537a9.tar.gz gcc-f07778f6f92111aa0abfd0f669b148a0bda537a9.tar.bz2 |
c++: dependence of constrained memfn from current inst [PR105842]
Here we incorrectly deem the calls to func1, func2 and tmpl2 as
ambiguous ahead of time ultimately because we mishandle dependence
of a constrained member function from the current instantiation.
In type_dependent_expression_p, we already consider dependence of a
TEMPLATE_DECL's constraints (via uses_outer_template_parms), but
neglect to do the same for a FUNCTION_DECL (such as that for func1).
And in satisfy_declaration_constraints, we give up if _any_ template
argument is dependent, but for non-dependent member functions from
the current instantiation (such as func2 and tmpl2), we can and must
check constraints as long as the innermost arguments aren't dependent.
PR c++/105842
gcc/cp/ChangeLog:
* constraint.cc (satisfy_declaration_constraints): Refine early
exit test for argument dependence.
* cp-tree.h (uses_outer_template_parms_in_constraints): Declare.
* pt.cc (template_class_depth): Handle TI_TEMPLATE being a
FIELD_DECL.
(usse_outer_template_parms): Factor out constraint dependence
test into ...
(uses_outer_template_parms_in_constraints): ... here.
(type_dependent_expression_p): Use it for FUNCTION_DECL.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/concepts-memtmpl6.C: New test.
Diffstat (limited to 'gcc/cp/constraint.cc')
-rw-r--r-- | gcc/cp/constraint.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 591155c..f2137eb 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -3176,9 +3176,15 @@ satisfy_declaration_constraints (tree t, sat_info info) args = regen_args; } - /* If any arguments depend on template parameters, we can't - check constraints. Pretend they're satisfied for now. */ - if (uses_template_parms (args)) + /* If the innermost arguments are dependent, or if the outer arguments + are dependent and are needed by the constraints, we can't check + satisfaction yet so pretend they're satisfied for now. */ + if (uses_template_parms (args) + && ((DECL_TEMPLATE_INFO (t) + && PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)) + && (TMPL_ARGS_DEPTH (args) == 1 + || uses_template_parms (INNERMOST_TEMPLATE_ARGS (args)))) + || uses_outer_template_parms_in_constraints (t))) return boolean_true_node; /* Get the normalized constraints. */ @@ -3240,9 +3246,13 @@ satisfy_declaration_constraints (tree t, tree args, sat_info info) else args = add_outermost_template_args (t, args); - /* If any arguments depend on template parameters, we can't - check constraints. Pretend they're satisfied for now. */ - if (uses_template_parms (args)) + /* If the innermost arguments are dependent, or if the outer arguments + are dependent and are needed by the constraints, we can't check + satisfaction yet so pretend they're satisfied for now. */ + if (uses_template_parms (args) + && (TMPL_ARGS_DEPTH (args) == 1 + || uses_template_parms (INNERMOST_TEMPLATE_ARGS (args)) + || uses_outer_template_parms_in_constraints (t))) return boolean_true_node; tree result = boolean_true_node; |