diff options
author | Jason Merrill <jason@yorick.cygnus.com> | 1998-10-17 23:01:39 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 1998-10-17 19:01:39 -0400 |
commit | 79c4d4b7a8d5fd71791609cb9f0d3d886a262ac9 (patch) | |
tree | 052db8fec597fc538db6606b34437b799069c5ba | |
parent | 1ddb2906ccd0c06c8164e781859485e8d0b3a2a7 (diff) | |
download | gcc-79c4d4b7a8d5fd71791609cb9f0d3d886a262ac9.zip gcc-79c4d4b7a8d5fd71791609cb9f0d3d886a262ac9.tar.gz gcc-79c4d4b7a8d5fd71791609cb9f0d3d886a262ac9.tar.bz2 |
decl.c (grokfndecl): Set DECL_CONTEXT to namespace if appropriate.
* decl.c (grokfndecl): Set DECL_CONTEXT to namespace if appropriate.
(grokvardecl): Likewise.
From-SVN: r23157
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 29 |
2 files changed, 24 insertions, 10 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 5dabdf8..c5bfc53 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +1998-10-17 Jason Merrill <jason@yorick.cygnus.com> + + * decl.c (grokfndecl): Set DECL_CONTEXT to namespace if appropriate. + (grokvardecl): Likewise. + Sat Oct 17 23:27:20 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * class.c (make_method_vec): Cast 1st argument of `bzero' to (PTR). diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 42cd6ba..40a04e4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8042,9 +8042,11 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, if (TYPE_VOLATILE (type)) TREE_THIS_VOLATILE (decl) = 1; - /* This decl is not from the current namespace. */ + /* If this decl has namespace scope, set that up. */ if (in_namespace) set_decl_namespace (decl, in_namespace); + else if (publicp && ! ctype) + DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace); /* `main' and builtins have implicit 'C' linkage. */ if ((MAIN_NAME_P (declarator) @@ -8053,11 +8055,9 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, && IDENTIFIER_POINTER (declarator)[1] == '_' && strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0)) && current_lang_name == lang_name_cplusplus - /* context == 0 could mean global scope or not set yet; either is fine - for us here, as we check current_namespace. */ - && DECL_CONTEXT (decl) == NULL_TREE && ctype == NULL_TREE - && current_namespace == global_namespace) + /* NULL_TREE means global namespace. */ + && DECL_CONTEXT (decl) == NULL_TREE) DECL_LANGUAGE (decl) = lang_c; /* Should probably propagate const out from type to decl I bet (mrs). */ @@ -8305,12 +8305,21 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace) } else { - tree context = in_namespace ? in_namespace : current_namespace; + tree context; + + if (in_namespace) + context = in_namespace; + else if (namespace_bindings_p () || RIDBIT_SETP (RID_EXTERN, specbits)) + context = current_namespace; + decl = build_decl (VAR_DECL, declarator, complete_type (type)); - if (declarator && context != global_namespace && namespace_bindings_p () - && current_lang_name != lang_name_c) - DECL_ASSEMBLER_NAME (decl) = build_static_name (context, - declarator); + + if (context) + set_decl_namespace (decl, context); + + context = DECL_CONTEXT (decl); + if (declarator && context && current_lang_name != lang_name_c) + DECL_ASSEMBLER_NAME (decl) = build_static_name (context, declarator); } if (in_namespace) |