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]

C++ PATCH: Builtins (3 of 3)



This patch changes the C++ compiler to never define builtins that do
not begin with `__builtin'.

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

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

2001-05-24  Mark Mitchell  <mark@codesourcery.com>

	* invoke.texi (-fno-builtin): Document that this is always on
	in C++.

2001-05-24  Mark Mitchell  <mark@codesourcery.com>

	* decl.c (duplicate_decls): Tidy.
	(init_decl_processing): Always set flag_no_builtin.

Index: gcc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/invoke.texi,v
retrieving revision 1.273.2.22
diff -c -p -r1.273.2.22 invoke.texi
*** invoke.texi	2001/05/21 15:57:55	1.273.2.22
--- invoke.texi	2001/05/25 00:56:01
*************** and faster, but since the function calls
*** 978,983 ****
--- 978,990 ----
  cannot set a breakpoint on those calls, nor can you change the behavior
  of the functions by linking with a different library.
  
+ In C++, @samp{-fno-builtin} is always in effect.  The @samp{-fbuiltin}
+ option has no effect.  Therefore, in C++, the only way to get the
+ optimization benefits of builtin functions is to call the function
+ using the @samp{__builtin_} prefix.  The GNU C++ Standard Library uses
+ builtin functions to implement many functions (like
+ @code{std::strchr}), so that you automatically get efficient code.
+ 
  @item -fhosted
  @cindex hosted environment
  
Index: gcc/cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.747.2.26
diff -c -p -r1.747.2.26 decl.c
*** decl.c	2001/05/13 07:10:20	1.747.2.26
--- decl.c	2001/05/25 00:56:07
*************** duplicate_decls (newdecl, olddecl)
*** 3722,3733 ****
  	    DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
  	}
      }
  
-   if (TREE_CODE (newdecl) == NAMESPACE_DECL)
-     {
-       NAMESPACE_LEVEL (newdecl) = NAMESPACE_LEVEL (olddecl);
-     }
- 
    /* Now preserve various other info from the definition.  */
    TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
    TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
--- 3722,3730 ----
  	    DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
  	}
      }
+   else if (TREE_CODE (newdecl) == NAMESPACE_DECL)
+     NAMESPACE_LEVEL (newdecl) = NAMESPACE_LEVEL (olddecl);
  
    /* Now preserve various other info from the definition.  */
    TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
    TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
*************** init_decl_processing ()
*** 6375,6380 ****
--- 6372,6383 ----
        flag_inline_trees = 2;
        flag_inline_functions = 0;
      }
+ 
+   /* In C++, we never create builtin functions whose name does not
+      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;


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