(C++) patch to equal_functions

Jason Merrill jason@redhat.com
Mon Oct 23 14:37:00 GMT 2000


See test below.

2000-10-23  Jason Merrill  <jason@redhat.com>

	* call.c (equal_functions): Also call decls_match for extern "C" fns.

Index: call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.232
diff -c -p -r1.232 call.c
*** call.c	2000/10/22 20:21:41	1.232
--- call.c	2000/10/23 21:36:14
*************** add_warning (winner, loser)
*** 4931,4944 ****
  }
  
  /* Returns true iff functions are equivalent. Equivalent functions are
!    not identical only if one is a function-local extern function.  */
  
  static inline int
  equal_functions (fn1, fn2)
       tree fn1;
       tree fn2;
  {
!   if (DECL_LOCAL_FUNCTION_P (fn1) || DECL_LOCAL_FUNCTION_P (fn2))
      return decls_match (fn1, fn2);
    return fn1 == fn2;
  }
--- 4931,4946 ----
  }
  
  /* Returns true iff functions are equivalent. Equivalent functions are
!    not '==' only if one is a function-local extern function or if
!    both are extern "C".  */
  
  static inline int
  equal_functions (fn1, fn2)
       tree fn1;
       tree fn2;
  {
!   if (DECL_LOCAL_FUNCTION_P (fn1) || DECL_LOCAL_FUNCTION_P (fn2)
!       || DECL_EXTERN_C_FUNCTION_P (fn1))
      return decls_match (fn1, fn2);
    return fn1 == fn2;
  }
Index: ../testsuite/g++.old-deja/g++.other/externC3.C
===================================================================
RCS file: externC3.C
diff -N externC3.C
*** /dev/null	Tue May  5 13:32:27 1998
--- ../testsuite/g++.old-deja/g++.other/externC3.C	Mon Oct 23 14:36:14 2000
***************
*** 0 ****
--- 1,15 ----
+ // Test that two extern "C" declarations of the same name in different
+ // namespaces are treated as declaring the same function.
+ 
+ namespace foo {
+   extern "C" int f ();
+ }
+ 
+ extern "C" int f () { return 0; }
+ 
+ using namespace foo;
+ 
+ int main ()
+ {
+   f ();
+ }


More information about the Gcc-patches mailing list