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]
Other format: [Raw text]

C++ PATCH: PR 9924


This patch fixes PR 9924, a problem with builtins and using
declarations.

(Remind me again why builtins aren't just marked specially when the
function is declared in C++?  Since functions can't be called without a
prototype in C++, creating all the builtins up front is just an
error-prone, wasteful way of getting where we want to get...)

Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery dot com

2003-03-11  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9924
	* g++.dg/overload/builtin2.C: New test.

2003-03-11  Mark Mitchell  <mark at codesourcery dot com>

	PR c++/9924
	* decl2.c (do_nonmember_using_decl): Ignore anticipated builtins.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.601
diff -c -5 -p -r1.601 decl2.c
*** cp/decl2.c	8 Mar 2003 09:12:52 -0000	1.601
--- cp/decl2.c	11 Mar 2003 22:56:38 -0000
*************** do_nonmember_using_decl (tree scope, tre
*** 4239,4263 ****
  	      else if (OVL_USED (tmp1))
  	        continue; /* this is a using decl */
  	      else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
  		  		  TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
  		{
-                   /* If this using declaration introduces a function
-                      recognized as a built-in, no longer mark it as
-                      anticipated in this scope.  */
-                   if (DECL_ANTICIPATED (old_fn))
-                     {
-                       DECL_ANTICIPATED (old_fn) = 0;
-                       break;
-                     }
- 
  	          /* There was already a non-using declaration in
  		     this scope with the same parameter types. If both
  	             are the same extern "C" functions, that's ok.  */
!                   if (!decls_match (new_fn, old_fn))
!     	            error ("`%D' is already declared in this scope", name);
! 		  break;
  		}
  	    }
  
  	  /* If we broke out of the loop, there's no reason to add
  	     this function to the using declarations for this
--- 4239,4269 ----
  	      else if (OVL_USED (tmp1))
  	        continue; /* this is a using decl */
  	      else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
  		  		  TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
  		{
  	          /* There was already a non-using declaration in
  		     this scope with the same parameter types. If both
  	             are the same extern "C" functions, that's ok.  */
!                   if (decls_match (new_fn, old_fn))
! 		    {
! 		      /* If the OLD_FN was a builtin, there is now a
! 			 real declaration.  */
! 		      if (DECL_ANTICIPATED (old_fn))
! 			DECL_ANTICIPATED (old_fn) = 0;
! 		      break;
! 		    }
! 		  else if (!DECL_ANTICIPATED (old_fn))
! 		    {
! 		      /* If the OLD_FN was really declared, the
! 			 declarations don't match.  */
! 		      error ("`%D' is already declared in this scope", name);
! 		      break;
! 		    }
! 
! 		  /* If the OLD_FN was not really there, just ignore
! 		     it and keep going.  */
  		}
  	    }
  
  	  /* If we broke out of the loop, there's no reason to add
  	     this function to the using declarations for this
Index: testsuite/g++.dg/overload/builtin2.C
===================================================================
RCS file: testsuite/g++.dg/overload/builtin2.C
diff -N testsuite/g++.dg/overload/builtin2.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/overload/builtin2.C	11 Mar 2003 22:58:05 -0000
***************
*** 0 ****
--- 1,8 ----
+ namespace __gnu_cxx {
+     void llabs(long long x);
+ }
+ 
+ namespace std {
+     using __gnu_cxx::llabs;
+     using __gnu_cxx::llabs;
+ }


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