C++ PATCH: Fix V3 build

Mark Mitchell mark@codesourcery.com
Thu Oct 19 10:59:00 GMT 2000


My change to put builtins in the `std' namespace broke code like:

  + extern "C" int memcmp (const void * __s1,
  + 		       const void * __s2,
  + 		       __SIZE_TYPE__ __n) throw ();
  + 
  + namespace std {
  + void f () {
  +   memcmp (0, 0, 0);
  + }
  + };

The problem was that the compiler was now finding the builtin, rather
than the global definition, which isn't right.

Fixed thusly.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2000-10-19  Mark Mitchell  <mark@codesourcery.com>

	* cp-tree.h (DECL_ANTICIPATED): Don't require a FUNCTION_DECL.
	* decl.c (select_decl): Don't return declarations that are
	DECL_ANTICIPATED.

Index: testsuite/g++.old-deja/g++.other/std1.C
===================================================================
RCS file: std1.C
diff -N std1.C
*** /dev/null	Tue May  5 13:32:27 1998
--- std1.C	Thu Oct 19 10:53:36 2000
***************
*** 0 ****
--- 1,13 ----
+ // Build don't link:
+ // Special g++ Options: -fhonor-std
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+ 
+ extern "C" int memcmp (const void * __s1,
+ 		       const void * __s2,
+ 		       __SIZE_TYPE__ __n) throw ();
+ 
+ namespace std {
+ void f () {
+   memcmp (0, 0, 0);
+ }
+ };
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.536
diff -c -p -r1.536 cp-tree.h
*** cp-tree.h	2000/10/18 18:59:03	1.536
--- cp-tree.h	2000/10/19 15:49:49
*************** extern int flag_new_for_scope;
*** 2481,2487 ****
  /* Nonzero if NODE is a FUNCTION_DECL for a built-in function, and we have
     not yet seen a prototype for that function.  */
  #define DECL_ANTICIPATED(NODE) \
!   (DECL_LANG_SPECIFIC (FUNCTION_DECL_CHECK (NODE))->decl_flags.anticipated_p)
  
  /* Record whether a typedef for type `int' was actually `signed int'.  */
  #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
--- 2481,2487 ----
  /* Nonzero if NODE is a FUNCTION_DECL for a built-in function, and we have
     not yet seen a prototype for that function.  */
  #define DECL_ANTICIPATED(NODE) \
!   (DECL_LANG_SPECIFIC (DECL_CHECK (NODE))->decl_flags.anticipated_p)
  
  /* Record whether a typedef for type `int' was actually `signed int'.  */
  #define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.699
diff -c -p -r1.699 decl.c
*** decl.c	2000/10/18 18:59:03	1.699
--- decl.c	2000/10/19 15:49:58
*************** select_decl (binding, flags)
*** 5693,5698 ****
--- 5693,5707 ----
  {
    tree val;
    val = BINDING_VALUE (binding);
+ 
+   /* When we implicitly declare some builtin entity, we mark it
+      DECL_ANTICIPATED, so that we know to ignore it until it is
+      really declared.  */
+   if (val && DECL_P (val) 
+       && DECL_LANG_SPECIFIC (val) 
+       && DECL_ANTICIPATED (val))
+     return NULL_TREE;
+ 
    if (LOOKUP_NAMESPACES_ONLY (flags))
      {
        /* We are not interested in types. */


More information about the Gcc-patches mailing list