PATCH: PR middle-end/20303: Can't push more than 16 nested visibility

H. J. Lu hjl@lucon.org
Wed May 18 00:00:00 GMT 2005


On Tue, May 17, 2005 at 01:54:34PM -0700, H. J. Lu wrote:
> On Tue, May 17, 2005 at 09:35:05PM +0100, Nathan Sidwell wrote:
> > H. J. Lu wrote:
> > 
> > > 
> > > 
> > > One minor correction. gengtype doesn't support GTY and non-GC VEC in
> > > the same .c file. If you believe it is untrue, show me one.
> > 
> > can you show me an example of what you mean?  tree.h contains definitions
> > of both heap and gc'd tree vectors for example.
> > 
> 
> Exactly, since there is a gc'd tree vector, so the type, tree, for
> heap vec is defined as far as gengtype is concerned.
> 
> This is the updated patch to use heap VEC.
> 
> 

This patch works around gengtype by using def_vec_o.


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

	PR middle-end/20303
	* c-pragma.c: Include "vec.h".
	(handle_pragma_visibility): Use VEC.

	* doc/invoke.texi: Remove the nested visibility push limit.

--- gcc/c-pragma.c.stack	2005-04-28 16:11:26.000000000 -0700
+++ gcc/c-pragma.c	2005-05-17 16:57:08.000000000 -0700
@@ -34,6 +34,7 @@ Software Foundation, 59 Temple Place - S
 #include "c-common.h"
 #include "output.h"
 #include "tm_p.h"
+#include "vec.h"
 #include "target.h"
 
 #define GCC_BAD(msgid) do { warning (0, msgid); return; } while (0)
@@ -583,15 +584,23 @@ maybe_apply_renaming_pragma (tree decl, 
 #ifdef HANDLE_PRAGMA_VISIBILITY
 static void handle_pragma_visibility (cpp_reader *);
 
+/* FIXME: This is to make gengtype happy.  */
+#define def_vec_o(T) DEF_VEC_O (T)
+typedef enum symbol_visibility visibility;
+def_vec_o (visibility);
+#undef def_vec_o
+DEF_VEC_ALLOC_O (visibility, heap);
+
 /* Sets the default visibility for symbols to something other than that
    specified on the command line.  */
 static void
 handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
-{ /* Form is #pragma GCC visibility push(hidden)|pop */
-  static int visstack [16], visidx;
+{
+  /* Form is #pragma GCC visibility push(hidden)|pop */
   tree x;
   enum cpp_ttype token;
   enum { bad, push, pop } action = bad;
+  static VEC (visibility, heap) *visstack;
  
   token = c_lex (&x);
   if (token == CPP_NAME)
@@ -608,14 +617,16 @@ handle_pragma_visibility (cpp_reader *du
     {
       if (pop == action)
         {
-          if (!visidx)
+          if (!VEC_length (visibility, visstack))
             {
               GCC_BAD ("No matching push for %<#pragma GCC visibility pop%>");
             }
           else
             {
-              default_visibility = visstack[--visidx];
-              visibility_options.inpragma = (visidx>0);
+	      default_visibility = *VEC_last (visibility, visstack);
+	      VEC_pop (visibility, visstack);
+	      visibility_options.inpragma
+		= VEC_length (visibility, visstack) != 0;
             }
         }
       else
@@ -627,14 +638,11 @@ handle_pragma_visibility (cpp_reader *du
             {
               GCC_BAD ("malformed #pragma GCC visibility push");
             }
-          else if (visidx >= 16)
-            {
-              GCC_BAD ("No more than sixteen #pragma GCC visibility pushes allowed at once");
-            }
           else
             {
               const char *str = IDENTIFIER_POINTER (x);
-              visstack[visidx++] = default_visibility;
+	      *VEC_safe_push (visibility, heap, visstack, NULL)
+		= default_visibility;
               if (!strcmp (str, "default"))
                 default_visibility = VISIBILITY_DEFAULT;
               else if (!strcmp (str, "internal"))
--- gcc/doc/invoke.texi.stack	2005-05-13 15:24:20.000000000 -0700
+++ gcc/doc/invoke.texi	2005-05-16 09:37:20.000000000 -0700
@@ -12706,8 +12706,8 @@ For those adding visibility support to e
 @samp{#pragma GCC visibility} of use.  This works by you enclosing
 the declarations you wish to set visibility for with (for example)
 @samp{#pragma GCC visibility push(hidden)} and
-@samp{#pragma GCC visibility pop}.  These can be nested up to sixteen
-times.  Bear in mind that symbol visibility should be viewed @strong{as
+@samp{#pragma GCC visibility pop}.
+Bear in mind that symbol visibility should be viewed @strong{as
 part of the API interface contract} and thus all new code should
 always specify visibility when it is not the default ie; declarations
 only for use within the local DSO should @strong{always} be marked explicitly



More information about the Gcc-patches mailing list