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]

PATCH for bad reporting of anonymous namespaces



On:

  namespace {
    struct S {
      void f();
    };
  }

  namespace {
    void S::f(int) {}
  }

we used to say:

  test5.C:8: prototype for `void ::_GLOBAL_.N.test5.C::S::f(int)' 
             does not match any in class `::_GLOBAL_.N.test5.C::S'
  test5.C:3: candidate is: void ::_GLOBAL_.N.test5.C::S::f()

Now, we say:

  test5.C:8: prototype for `void {anonymous}::S::f(int)' does not
             match any in class `{anonymous}::S'
  test5.C:3: candidate is: void {anonymous}::S::f()

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1998-09-08  Mark Mitchell  <mark@markmitchell.com>

	* cp-tree.h (anonymous_namespace_name): Declare.
	* decl.c: Define it.
	(push_namespace): Use anonymous_namespace_name, rather than local
	static anon_name.
	* error.c (dump_decl): If a namespace is named
	anonymous_namespace_name, call it {anonymous}.

Index: cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.137
diff -c -p -r1.137 cp-tree.h
*** cp-tree.h	1998/09/07 14:25:00	1.137
--- cp-tree.h	1998/09/08 18:30:07
*************** extern tree integer_two_node, integer_th
*** 1923,1928 ****
--- 1930,1937 ----
  extern tree boolean_type_node, boolean_true_node, boolean_false_node;
  
  extern tree null_node;
+ 
+ extern tree anonymous_namespace_name;
  
  /* in pt.c  */
  
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.207
diff -c -p -r1.207 decl.c
*** decl.c	1998/09/08 10:04:36	1.207
--- decl.c	1998/09/08 18:30:47
*************** extern tree previous_class_values;
*** 559,564 ****
--- 559,568 ----
     node, but signed.  */
  tree signed_size_zero_node;
  
+ /* The name of the anonymous namespace, throughout this translation
+    unit.  */
+ tree anonymous_namespace_name;
+ 
  
  /* Allocate a level of searching.  */
  
*************** push_namespace (name)
*** 1783,1792 ****
      {
        /* The name of anonymous namespace is unique for the translation
           unit.  */
!       static tree anon_name = NULL_TREE;
!       if (!anon_name)
!         anon_name = get_file_function_name ('N');
!       name = anon_name;
        d = IDENTIFIER_NAMESPACE_VALUE (name);
        if (d)
          /* Reopening anonymous namespace.  */
--- 1787,1795 ----
      {
        /* The name of anonymous namespace is unique for the translation
           unit.  */
!       if (!anonymous_namespace_name)
!         anonymous_namespace_name = get_file_function_name ('N');
!       name = anonymous_namespace_name;
        d = IDENTIFIER_NAMESPACE_VALUE (name);
        if (d)
          /* Reopening anonymous namespace.  */
Index: error.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/error.c,v
retrieving revision 1.51
diff -c -p -r1.51 error.c
*** error.c	1998/08/30 17:45:15	1.51
--- error.c	1998/09/08 18:30:50
*************** dump_decl (t, v)
*** 733,739 ****
  	  dump_decl (DECL_CONTEXT (t), v);
  	  OB_PUTC2 (':',':');
  	}
!       OB_PUTID (DECL_NAME (t));
        break;
  
      case SCOPE_REF:
--- 733,742 ----
  	  dump_decl (DECL_CONTEXT (t), v);
  	  OB_PUTC2 (':',':');
  	}
!       if (DECL_NAME (t) == anonymous_namespace_name)
! 	OB_PUTS ("{anonymous}");
!       else
! 	OB_PUTID (DECL_NAME (t));
        break;
  
      case SCOPE_REF:


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