diff options
author | Nathan Sidwell <nathan@acm.org> | 2020-07-28 08:57:36 -0700 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2020-07-28 09:01:32 -0700 |
commit | f3665bd1111c1799c0421490b5e655f977570354 (patch) | |
tree | 57a656ea045c750c559b5af198cc0301b2275ad4 /gcc/cp | |
parent | 0cd58a9f091b39c5e41b7954d6c4bd88f3567d49 (diff) | |
download | gcc-f3665bd1111c1799c0421490b5e655f977570354.zip gcc-f3665bd1111c1799c0421490b5e655f977570354.tar.gz gcc-f3665bd1111c1799c0421490b5e655f977570354.tar.bz2 |
c++: Set more DECL_CONTEXTs
I discovered we were not setting DECL_CONTEXT in a few cases, and
grokfndecl's control flow wasn't making it clear that we were doing it
in all cases.
gcc/cp/
* cp-gimplify.c (cp_genericize_r): Set IMPORTED_DECL's context.
* cp-objcp-common.c (cp_pushdecl): Set decl's context.
* decl.c (grokfndecl): Make DECL_CONTEXT setting clearer.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cp-gimplify.c | 1 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.c | 3 | ||||
-rw-r--r-- | gcc/cp/decl.c | 12 |
3 files changed, 8 insertions, 8 deletions
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 0e949e2..f869583 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1495,6 +1495,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) { tree using_directive = make_node (IMPORTED_DECL); TREE_TYPE (using_directive) = void_type_node; + DECL_CONTEXT (using_directive) = current_function_decl; IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl; DECL_CHAIN (using_directive) = BLOCK_VARS (block); diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index dfd8be9..fecf866 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -332,11 +332,12 @@ cp_get_global_decls () return NAMESPACE_LEVEL (global_namespace)->names; } -/* Push DECL into the current scope. */ +/* Push DECL into the current (namespace) scope. */ tree cp_pushdecl (tree decl) { + DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); return pushdecl (decl); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 385b1f3..b4beaa9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9560,7 +9560,9 @@ grokfndecl (tree ctype, /* If this decl has namespace scope, set that up. */ if (in_namespace) set_decl_namespace (decl, in_namespace, friendp); - else if (!ctype) + else if (ctype) + DECL_CONTEXT (decl) = ctype; + else DECL_CONTEXT (decl) = FROB_CONTEXT (current_decl_namespace ()); /* `main' and builtins have implicit 'C' linkage. */ @@ -9588,12 +9590,8 @@ grokfndecl (tree ctype, if (deletedp) DECL_DELETED_FN (decl) = 1; - if (ctype) - { - DECL_CONTEXT (decl) = ctype; - if (funcdef_flag) - check_class_member_definition_namespace (decl); - } + if (ctype && funcdef_flag) + check_class_member_definition_namespace (decl); if (ctype == NULL_TREE && DECL_MAIN_P (decl)) { |