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]

PATCH: PR middle-end/20297: #pragma GCC visibility isn't properly handled for builtin functions


On Thu, Mar 03, 2005 at 08:53:13AM -0800, H. J. Lu wrote:
> On Thu, Mar 03, 2005 at 11:12:35AM -0500, Matthew L Daniel wrote:
> > [I'm putting this back on the list so future generations can benefit
> > from this discussion; also so I can point the Mozilla folk to this
> > thread]
> > 
> > > It is a bug in source. If you count "#pragma GCC visibility", you will
> > > find there is one more push than pop. After you add the missing pop,
> > > everything should be OK. Unfortunately, gcc doesn't warn about it.
> > 
> > I was not aware that #pragma lines were something under my control at
> > the source level (even though it's not "my" code).
> > 
> > In short, can you advise some steps I (or the owners of nsprpub) can
> > take to resolve that?
> 
> It is a gcc bug
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20297
> 
> 

This patch seems to work for me.


H.J.
---
2005-03-03  H.J. Lu  <hongjiu.lu@intel.com>

	PR middle-end/20297
	* builtins.c (expand_builtin_1): Renamed from expand_builtin.
	(expand_builtin): Save/restore default_visibility and
	visibility_options.inpragma when calling expand_builtin_1.

--- gcc/builtins.c.push	2005-03-02 09:34:03.000000000 -0800
+++ gcc/builtins.c	2005-03-03 11:00:03.932066873 -0800
@@ -4944,9 +4944,9 @@ expand_builtin_sprintf (tree arglist, rt
    SUBTARGET may be used as the target for computing one of EXP's operands.
    IGNORE is nonzero if the value is to be ignored.  */
 
-rtx
-expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
-		int ignore)
+static rtx
+expand_builtin_1 (tree exp, rtx target, rtx subtarget,
+		  enum machine_mode mode, int ignore)
 {
   tree fndecl = get_callee_fndecl (exp);
   tree arglist = TREE_OPERAND (exp, 1);
@@ -5548,6 +5548,27 @@ expand_builtin (tree exp, rtx target, rt
   return expand_call (exp, target, ignore);
 }
 
+rtx
+expand_builtin (tree exp, rtx target, rtx subtarget,
+		enum machine_mode mode, int ignore)
+{
+  enum symbol_visibility saved_visibility = default_visibility;
+  unsigned int saved_inpragma = visibility_options.inpragma;
+  rtx expanded;
+
+  /* We should use the original visibility of the builtin function
+     declaration.  */
+  default_visibility = DECL_VISIBILITY (exp);
+  visibility_options.inpragma = DECL_VISIBILITY_SPECIFIED (exp);
+
+  expanded = expand_builtin_1 (exp, target, subtarget, mode, ignore);
+
+  default_visibility = saved_visibility;
+  visibility_options.inpragma = saved_inpragma;
+
+  return expanded;
+}
+
 /* Determine whether a tree node represents a call to a built-in
    function.  If the tree T is a call to a built-in function with
    the right number of arguments of the appropriate types, return


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