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

[PATCH] Builtins and C++ and such



> I suppose so.  He who writes the code makes the rules...

Not being one to back away from being controversial. I thought I'd
get around to submitting the following patch.

When applied in conjunction with my "std and global namespaces"
patch http://gcc.gnu.org/ml/gcc-patches/2001-12/msg00297.html, this
fixes the orginial correctness issue that prompted Mark Mitchell to
disable builtins in the C++ front-end, re-enables g++ built-ins and
correctly recognizes the memset call that started this current thread.

This has survived "make bootstrap" and "make -k check" on
i686-pc-linux-gnu both with and without the hunk that explicitly
re-enables builtins.  No new testsuite regressions (double checked
checked for libstdc++ and g++).  I'll start another bootstrap on
both alphaev67-dec-osf5.1 and powerpc-ibm-aix5.1.0.0 when I get
into the office.

This patch has been used in our local tree for several months.
The observant may have noticed the reference to BENCH++ improvements
in http://gcc.gnu.org/ml/gcc/2002-02/msg00307.html.  Indeed we've
been using it to ship higher performance C++ binaries to customers.

I was waiting until after the 3.1 branch to submit it for review.
Unfortunately, as soon as 3.1 branched, mainline was hit with a
deluge of de-stablizing pacthes, so I've been waiting for a good
time.  I'd also have prefered to submit parallel patches to fix
g++'s "-fno-builtin" and "-fno-builtin-<func>" command line options
(to be double safe), but the current thread has forced my hand.

[Finally to answer my earlier critics that this should have been
co-ordinated with the libstdc++ and glibc folks, please note my
builtins patches to those projects, i.e. I am also a libstdc++
and a glibc person].


I hope this livens up the debate :>


2002-03-20  Roger Sayle  <roger@eyesopen.com>
	* decl.c (lookup_namespace_name): Fail to find an identifier in
	the specified namespace if its still anticipated.
	* decl2.c (do_nonmember_using_decl): If a using specifies an
	anticipated built-in, no longer mark it as anticipated in that
	scope.

	* decl.c (cxx_init_decl_processing): Re-enable built-in
        function in the g++ front-end.


diff -c3pr gcc/gcc/cp/decl.c patch+/gcc/cp/decl.c
*** gcc/gcc/cp/decl.c	Tue Mar 19 21:31:30 2002
--- patch+/gcc/cp/decl.c	Wed Mar 20 00:52:31 2002
*************** lookup_namespace_name (namespace, name)
*** 5507,5513 ****
        /* If we have a single function from a using decl, pull it out.  */
        if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val))
  	val = OVL_FUNCTION (val);
!       return val;
      }

    error ("`%D' undeclared in namespace `%D'", name, namespace);
--- 5507,5518 ----
        /* If we have a single function from a using decl, pull it out.  */
        if (TREE_CODE (val) == OVERLOAD && ! really_overloaded_fn (val))
  	val = OVL_FUNCTION (val);
!
!       /* Ignore built-in functions that haven't been prototyped yet.  */
!       if (!val || !DECL_P(val)
!           || !DECL_LANG_SPECIFIC(val)
!           || !DECL_ANTICIPATED (val))
!         return val;
      }

    error ("`%D' undeclared in namespace `%D'", name, namespace);
*************** cxx_init_decl_processing ()
*** 6439,6445 ****
       begin with `__'.  Users should be using headers to get prototypes
       in C++.  It would be nice if we could warn when `-fbuiltin' is
       used explicitly, but we do not have that information.  */
!   flag_no_builtin = 1;

    /* Initially, C.  */
    current_lang_name = lang_name_c;
--- 6444,6450 ----
       begin with `__'.  Users should be using headers to get prototypes
       in C++.  It would be nice if we could warn when `-fbuiltin' is
       used explicitly, but we do not have that information.  */
!   flag_no_builtin = 0;

    /* Initially, C.  */
    current_lang_name = lang_name_c;
diff -c3pr gcc/gcc/cp/decl2.c patch+/gcc/cp/decl2.c
*** gcc/gcc/cp/decl2.c	Sat Mar 16 13:29:48 2002
--- patch+/gcc/cp/decl2.c	Tue Mar 19 23:41:51 2002
*************** do_nonmember_using_decl (scope, name, ol
*** 4941,4946 ****
--- 4941,4955 ----
  	      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.  */

Roger
--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-473-0833

"Some said we didn't have the programming language to represent your
perfect world" - Agent Smith, The Matrix.




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