aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-09-10 16:36:21 -0400
committerJason Merrill <jason@redhat.com>2021-09-15 16:26:15 -0400
commit30e025393209e1936c394e716006cdaaa6d50161 (patch)
treeb1e8f9db52b12a3a11ee3a64fde5c02186e32633 /gcc/cp/name-lookup.c
parente5d1af8a07ae9fcc40ea5c781c3ad46d20ea12a6 (diff)
downloadgcc-30e025393209e1936c394e716006cdaaa6d50161.zip
gcc-30e025393209e1936c394e716006cdaaa6d50161.tar.gz
gcc-30e025393209e1936c394e716006cdaaa6d50161.tar.bz2
c++: add parsing_function_declarator predicate
While looking at PR96184 I noticed that we were recognizing the situation of parsing a function declarator based on current_binding_level, and that we ought to make that a predicate function. This patch is just refactoring, but I just suggested using it in a review of another patch. gcc/cp/ChangeLog: * cp-tree.h (parsing_function_declarator): Declare. * name-lookup.c (set_decl_context_in_fn): Use it. * parser.c (cp_parser_direct_declarator): Use it. (parsing_function_declarator): New.
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 8e9c61e..ddee8b3 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3363,12 +3363,9 @@ set_decl_context_in_fn (tree ctx, tree decl)
if (!DECL_CONTEXT (decl)
/* When parsing the parameter list of a function declarator,
- don't set DECL_CONTEXT to an enclosing function. When we
- push the PARM_DECLs in order to process the function body,
- current_binding_level->this_entity will be set. */
+ don't set DECL_CONTEXT to an enclosing function. */
&& !(TREE_CODE (decl) == PARM_DECL
- && current_binding_level->kind == sk_function_parms
- && current_binding_level->this_entity == NULL))
+ && parsing_function_declarator ()))
DECL_CONTEXT (decl) = ctx;
}