diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-02-26 10:43:28 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-02-26 10:43:28 +0100 |
commit | 27f9a87886d48448f83e0e559dcf028b1a4a4ec6 (patch) | |
tree | 329c66032438ccd1c0067bb64606aa38ac99789b /gcc/cp/lambda.c | |
parent | ff7a5154460e2830e244c350cc8f7c35913de70e (diff) | |
download | gcc-27f9a87886d48448f83e0e559dcf028b1a4a4ec6.zip gcc-27f9a87886d48448f83e0e559dcf028b1a4a4ec6.tar.gz gcc-27f9a87886d48448f83e0e559dcf028b1a4a4ec6.tar.bz2 |
c++: Fix operator() lookup in lambdas [PR95451]
During name lookup, name-lookup.c uses:
if (!(!iter->type && HIDDEN_TYPE_BINDING_P (iter))
&& (bool (want & LOOK_want::HIDDEN_LAMBDA)
|| !is_lambda_ignored_entity (iter->value))
&& qualify_lookup (iter->value, want))
binding = iter->value;
Unfortunately as the following testcase shows, this doesn't work in
generic lambdas, where we on the auto b = ... lambda ICE and on the
auto d = lambda reject it even when it should be valid. The problem
is that the binding doesn't have a FUNCTION_DECL with
LAMBDA_FUNCTION_P for the operator(), but an OVERLOAD with
TEMPLATE_DECL for such FUNCTION_DECL.
The following patch fixes that in is_lambda_ignored_entity, other
possibility would be to do that before calling is_lambda_ignored_entity
in name-lookup.c.
2021-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/95451
* lambda.c (is_lambda_ignored_entity): Before checking for
LAMBDA_FUNCTION_P, use OVL_FIRST. Drop FUNCTION_DECL check.
* g++.dg/cpp1y/lambda-generic-95451.C: New test.
Diffstat (limited to 'gcc/cp/lambda.c')
-rw-r--r-- | gcc/cp/lambda.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index 586b7ff..421685c 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -1352,7 +1352,8 @@ is_lambda_ignored_entity (tree val) /* None of the lookups that use qualify_lookup want the op() from the lambda; they want the one from the enclosing class. */ - if (TREE_CODE (val) == FUNCTION_DECL && LAMBDA_FUNCTION_P (val)) + val = OVL_FIRST (val); + if (LAMBDA_FUNCTION_P (val)) return true; return false; |