This is the mail archive of the gcc-bugs@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]

Re: Qualified friends


> I can guess why this is so, as we're smashing ::std into ::, and
> clearly it's been missed somewhere.

Correct. I've updated the previous patch; you'll have to reverse that
one before applying this one. I guess I make a test case for
everything once you don't find new problems, anymore :-)

Thanks,
Martin

1999-02-25  Martin von Löwis  <loewis@informatik.hu-berlin.de>

	* decl.c (grokdeclarator): Consider std_node when setting
	in_namespace. Set current_namespace when pushing friends.
	(grokfndecl): Likewise, for mangling.
	
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.312
diff -c -p -r1.312 decl.c
*** decl.c	1999/02/21 16:38:14	1.312
--- decl.c	1999/02/24 23:43:25
*************** grokfndecl (ctype, type, declarator, ori
*** 8512,8518 ****
    if (! ctype && ! processing_template_decl
        && DECL_LANGUAGE (decl) != lang_c
        && (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1))
!     set_mangled_name_for_decl (decl);
  
    if (funcdef_flag)
      /* Make the init_value nonzero so pushdecl knows this is not
--- 8512,8526 ----
    if (! ctype && ! processing_template_decl
        && DECL_LANGUAGE (decl) != lang_c
        && (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1))
!     {
!       /* When mangling, we need current_namespace to be the namespace
!          of the decl we are making.  */
!       tree saved_namespace = current_namespace;
!       if (in_namespace)
! 	current_namespace = in_namespace;
!       set_mangled_name_for_decl (decl);
!       current_namespace = saved_namespace;
!     }
  
    if (funcdef_flag)
      /* Make the init_value nonzero so pushdecl knows this is not
*************** grokdeclarator (declarator, declspecs, d
*** 9108,9113 ****
--- 9116,9123 ----
  		{
  		  ctype = NULL_TREE;
  		  in_namespace = TREE_OPERAND (decl, 0);
+ 		  if (in_namespace == std_node)
+ 		    in_namespace = global_namespace;
  		  TREE_OPERAND (decl, 0) = NULL_TREE;
  		}
  	      else if (! is_aggr_type (cname, 1))
*************** grokdeclarator (declarator, declspecs, d
*** 11029,11034 ****
--- 11039,11045 ----
  		tree t = NULL_TREE;
  		if (decl && DECL_NAME (decl))
  		  {
+ 		    tree saved_namespace = current_namespace;
  		    if (template_class_depth (current_class_type) == 0)
  		      {
  			decl 
*************** grokdeclarator (declarator, declspecs, d
*** 11039,11047 ****
--- 11050,11067 ----
  			  return error_mark_node;
  		      }
  
+ 		    /* If we have an explicit global_scope for the
+ 		       friend we still have no DECL_CONTEXT on it
+ 		       (since global_namespace is represented by 0).
+ 		       pushdecl will then think it has to set the context,
+ 		       based on current_namespace.  */
+ 
+ 		    if (in_namespace)
+ 		      current_namespace = in_namespace;
  		    t = do_friend (ctype, declarator, decl,
  				   last_function_parms, flags, quals,
  				   funcdef_flag);
+ 		    current_namespace = saved_namespace;
  		  }
  		if (t && funcdef_flag)
  		  return t;


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