Commit be1b1c9b by H.J. Lu Committed by H.J. Lu

re PR c/20303 ([4.0 only] Can't push more than 16 nested visibility)

2005-05-30  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.

From-SVN: r100371
parent 385e0e08
2005-05-30 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.
2005-05-30 Roger Sayle <roger@eyesopen.com> 2005-05-30 Roger Sayle <roger@eyesopen.com>
PR rtl-optimization/15422 PR rtl-optimization/15422
......
...@@ -34,6 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -34,6 +34,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "c-common.h" #include "c-common.h"
#include "output.h" #include "output.h"
#include "tm_p.h" #include "tm_p.h"
#include "vec.h"
#include "target.h" #include "target.h"
#define GCC_BAD(msgid) do { warning (0, msgid); return; } while (0) #define GCC_BAD(msgid) do { warning (0, msgid); return; } while (0)
...@@ -585,15 +586,20 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) ...@@ -585,15 +586,20 @@ maybe_apply_renaming_pragma (tree decl, tree asmname)
#ifdef HANDLE_PRAGMA_VISIBILITY #ifdef HANDLE_PRAGMA_VISIBILITY
static void handle_pragma_visibility (cpp_reader *); static void handle_pragma_visibility (cpp_reader *);
typedef enum symbol_visibility visibility;
DEF_VEC_I (visibility);
DEF_VEC_ALLOC_I (visibility, heap);
/* Sets the default visibility for symbols to something other than that /* Sets the default visibility for symbols to something other than that
specified on the command line. */ specified on the command line. */
static void static void
handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) 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; tree x;
enum cpp_ttype token; enum cpp_ttype token;
enum { bad, push, pop } action = bad; enum { bad, push, pop } action = bad;
static VEC (visibility, heap) *visstack;
token = c_lex (&x); token = c_lex (&x);
if (token == CPP_NAME) if (token == CPP_NAME)
...@@ -610,14 +616,15 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) ...@@ -610,14 +616,15 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
{ {
if (pop == action) if (pop == action)
{ {
if (!visidx) if (!VEC_length (visibility, visstack))
{ {
GCC_BAD ("No matching push for %<#pragma GCC visibility pop%>"); GCC_BAD ("No matching push for %<#pragma GCC visibility pop%>");
} }
else else
{ {
default_visibility = visstack[--visidx]; default_visibility = VEC_pop (visibility, visstack);
visibility_options.inpragma = (visidx>0); visibility_options.inpragma
= VEC_length (visibility, visstack) != 0;
} }
} }
else else
...@@ -629,14 +636,11 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) ...@@ -629,14 +636,11 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
{ {
GCC_BAD ("malformed #pragma GCC visibility push"); 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 else
{ {
const char *str = IDENTIFIER_POINTER (x); const char *str = IDENTIFIER_POINTER (x);
visstack[visidx++] = default_visibility; VEC_safe_push (visibility, heap, visstack,
default_visibility);
if (!strcmp (str, "default")) if (!strcmp (str, "default"))
default_visibility = VISIBILITY_DEFAULT; default_visibility = VISIBILITY_DEFAULT;
else if (!strcmp (str, "internal")) else if (!strcmp (str, "internal"))
......
...@@ -12774,8 +12774,8 @@ For those adding visibility support to existing code, you may find ...@@ -12774,8 +12774,8 @@ For those adding visibility support to existing code, you may find
@samp{#pragma GCC visibility} of use. This works by you enclosing @samp{#pragma GCC visibility} of use. This works by you enclosing
the declarations you wish to set visibility for with (for example) the declarations you wish to set visibility for with (for example)
@samp{#pragma GCC visibility push(hidden)} and @samp{#pragma GCC visibility push(hidden)} and
@samp{#pragma GCC visibility pop}. These can be nested up to sixteen @samp{#pragma GCC visibility pop}.
times. Bear in mind that symbol visibility should be viewed @strong{as Bear in mind that symbol visibility should be viewed @strong{as
part of the API interface contract} and thus all new code should part of the API interface contract} and thus all new code should
always specify visibility when it is not the default ie; declarations always specify visibility when it is not the default ie; declarations
only for use within the local DSO should @strong{always} be marked explicitly only for use within the local DSO should @strong{always} be marked explicitly
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment