On Mon, 8 Feb 2021, Patrick Palka wrote: > This fixes the way we check satisfaction of constraints on placeholder > types in various contexts, and in particular when the constraint is > dependent. > > Firstly, when evaluating the return type requirement of a compound > requirement, we currently substitute the outer template arguments into > the constraint before checking satisfaction. But we should instead be > passing in the complete set of template arguments to satisfaction and > not do a prior separate substitution. Our current approach leads to us > incorrectly rejecting the testcase concepts-return-req2.C below. > > Secondly, when checking the constraints on a placeholder variable or > return type, we don't substitute the template arguments of the enclosing > context at all. This leads to bogus errors during satisfaction when the > constraint is dependent as in the testcase concepts-placeholder3.C > below. > > In order to fix these two issues, we need to be able to properly > normalize the constraints on a placeholder 'auto', which in turn > requires us to know the template parameters that were in-scope where an > 'auto' was introduced. This information currently doesn't seem to be > easily available when we need it, so this patch adds an auxiliary hash > table that keeps track of the value of current_template_parms when each > constrained 'auto' was formed. > > This patch also removes some seemingly wrong handling of placeholder > type arguments from tsubst_parameter_mapping. The code doesn't trigger > with the example used in the comments, because type_uses_auto doesn't > look inside non-deduced contexts such as the operand of decltype. And > the call to do_auto_deduction seems confused because if 'arg' is a type, > then so is 'parm', and therefore 'init' too is a type, but > do_auto_deduction expects it to be an expression. Before this patch, > this code was dead (as far as our testsuite can tell), but now it breaks > other parts of this patch, so let's remove it.
This series was bootstrapped and regtested on x86_64-pc-linux-gnu and tested on range-v3 and cmcstl2, with and without --enable-checking=release.