diff options
author | Jason Merrill <jason@redhat.com> | 2022-04-13 16:42:25 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-04-13 20:24:36 -0400 |
commit | 1824da60663b4532199ecd051d8ba6da8995821d (patch) | |
tree | 52bc8b3bc1d5569d87d6895f6d7af0da58d8c59e /gcc/cp/cp-tree.h | |
parent | d4e00ccef6c706a4a4a6446bffaf4111f98d5771 (diff) | |
download | gcc-1824da60663b4532199ecd051d8ba6da8995821d.zip gcc-1824da60663b4532199ecd051d8ba6da8995821d.tar.gz gcc-1824da60663b4532199ecd051d8ba6da8995821d.tar.bz2 |
c++: local fn and generic lambda [PR97219]
When instantiating the op() for a generic lambda, we can no longer do name
lookup inside function scopes enclosing the lambda, so we need to remember
the lookup result from processing the definition of the lambda. So the code
in finish_call_expr to throw away the lookup result and instead look it up
again at instantiation time needs to be adjusted. The approach I take is to
only discard the result if the local extern comes from dependent scope; once
the enclosing function template is instantiated and we're regenerating the
lambda, then we can remember the result of lookup. We also need any default
arguments to be instantiated at that point.
PR c++/97219
gcc/cp/ChangeLog:
* name-lookup.cc (dependent_local_decl_p): New.
* cp-tree.h (dependent_local_decl_p): Declare.
* semantics.cc (finish_call_expr): Use it.
* pt.cc (tsubst_arg_types): Also substitute default args
for local externs.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-local-fn1.C: New test.
Diffstat (limited to 'gcc/cp/cp-tree.h')
-rw-r--r-- | gcc/cp/cp-tree.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 2f71885..e9a3d09 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -8243,6 +8243,7 @@ extern tree fold_builtin_source_location (location_t); /* in name-lookup.cc */ extern tree strip_using_decl (tree); extern void diagnose_name_conflict (tree, tree); +extern bool dependent_local_decl_p (tree); /* Tell the binding oracle what kind of binding we are looking for. */ |