This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

(C++) patch for g++.ns/extern1.C


We need to take current_namespace into account when generating static
names, and we might as well do that by putting it into DECL_CONTEXT
immediately, rather than waiting until pushdecl.

1998-10-17  Jason Merrill  <jason@yorick.cygnus.com>

	* decl.c (grokfndecl): Set DECL_CONTEXT to namespace if appropriate.
	(grokvardecl): Likewise.

Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.236
diff -c -p -r1.236 decl.c
*** decl.c	1998/10/16 18:40:36	1.236
--- decl.c	1998/10/18 05:58:54
*************** grokfndecl (ctype, type, declarator, ori
*** 8042,8050 ****
    if (TYPE_VOLATILE (type))
      TREE_THIS_VOLATILE (decl) = 1;
  
!   /* This decl is not from the current namespace. */
    if (in_namespace)
      set_decl_namespace (decl, in_namespace);
  
    /* `main' and builtins have implicit 'C' linkage.  */
    if ((MAIN_NAME_P (declarator)
--- 8042,8052 ----
    if (TYPE_VOLATILE (type))
      TREE_THIS_VOLATILE (decl) = 1;
  
!   /* 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)
*************** grokfndecl (ctype, type, declarator, ori
*** 8053,8063 ****
  	   && 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)
      DECL_LANGUAGE (decl) = lang_c;
  
    /* Should probably propagate const out from type to decl I bet (mrs).  */
--- 8055,8063 ----
  	   && IDENTIFIER_POINTER (declarator)[1] == '_'
  	   && strncmp (IDENTIFIER_POINTER (declarator)+2, "builtin_", 8) == 0))
        && current_lang_name == lang_name_cplusplus
        && ctype == NULL_TREE
!       /* 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).  */
*************** grokvardecl (type, declarator, specbits_
*** 8305,8316 ****
      }
    else
      {
!       tree context = in_namespace ? in_namespace : 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 (in_namespace)
--- 8305,8325 ----
      }
    else
      {
!       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 (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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]