Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / gnu / usr.bin / cc34 / cc_prep / patches / c-pragma.c.patch
1 $DragonFly: src/gnu/usr.bin/cc34/cc_prep/patches/c-pragma.c.patch,v 1.1 2004/12/21 13:10:48 joerg Exp $
2
3 ===================================================================
4 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/c-pragma.c,v
5 retrieving revision 1.1
6 diff -u -r1.1 c-pragma.c
7 --- c-pragma.c  20 Jun 2004 02:14:48 -0000      1.1
8 +++ c-pragma.c  20 Dec 2004 20:51:37 -0000
9 @@ -481,6 +481,86 @@
10    return asmname;
11  }
12  
13 +
14 +#ifdef HANDLE_PRAGMA_VISIBILITY
15 +static void handle_pragma_visibility (cpp_reader *);
16 +
17 +/* Sets the default visibility for symbols to something other than that
18 +   specified on the command line.  */
19 +static void
20 +handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED)
21 +{ /* Form is #pragma GCC visibility push(hidden)|pop */
22 +  static int visstack [16], visidx;
23 +  tree x;
24 +  enum cpp_ttype token;
25 +  enum { bad, push, pop } action = bad;
26
27 +  token = c_lex (&x);
28 +  if (token == CPP_NAME)
29 +    {
30 +      const char *op = IDENTIFIER_POINTER (x);
31 +      if (!strcmp (op, "push"))
32 +        action = push;
33 +      else if (!strcmp (op, "pop"))
34 +        action = pop;
35 +    }
36 +  if (bad == action)
37 +    GCC_BAD ("#pragma GCC visibility must be followed by push or pop");
38 +  else
39 +    {
40 +      if (pop == action)
41 +        {
42 +          if (!visidx)
43 +            {
44 +              GCC_BAD ("No matching push for '#pragma GCC visibility pop'");
45 +            }
46 +          else
47 +            {
48 +              default_visibility = visstack[--visidx];
49 +              visibility_options.inpragma = (visidx>0);
50 +            }
51 +        }
52 +      else
53 +        {
54 +          if (c_lex (&x) != CPP_OPEN_PAREN)
55 +            GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored");
56 +          token = c_lex (&x);
57 +          if (token != CPP_NAME)
58 +            {
59 +              GCC_BAD ("malformed #pragma GCC visibility push");
60 +            }
61 +          else if (visidx >= 16)
62 +            {
63 +              GCC_BAD ("No more than sixteen #pragma GCC visibility pushes allowed at once");
64 +            }
65 +          else
66 +            {
67 +              const char *str = IDENTIFIER_POINTER (x);
68 +              visstack[visidx++] = default_visibility;
69 +              if (!strcmp (str, "default"))
70 +                default_visibility = VISIBILITY_DEFAULT;
71 +              else if (!strcmp (str, "internal"))
72 +                default_visibility = VISIBILITY_INTERNAL;
73 +              else if (!strcmp (str, "hidden"))
74 +                default_visibility = VISIBILITY_HIDDEN;  
75 +              else if (!strcmp (str, "protected"))
76 +                default_visibility = VISIBILITY_PROTECTED;
77 +              else
78 +                {
79 +                  GCC_BAD ("#pragma GCC visibility push() must specify default, internal, hidden or protected");
80 +                }
81 +              visibility_options.inpragma = 1;
82 +            }
83 +          if (c_lex (&x) != CPP_CLOSE_PAREN)
84 +            GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored");
85 +        }
86 +    }
87 +  if (c_lex (&x) != CPP_EOF)
88 +    warning ("junk at end of '#pragma GCC visibility'");
89 +}
90 +
91 +#endif
92 +
93  /* Front-end wrapper for pragma registration to avoid dragging
94     cpplib.h in almost everywhere.  */
95  void
96 @@ -506,6 +586,9 @@
97  #ifdef HANDLE_PRAGMA_EXTERN_PREFIX
98    c_register_pragma (0, "extern_prefix", handle_pragma_extern_prefix);
99  #endif
100 +#ifdef HANDLE_PRAGMA_VISIBILITY
101 +  c_register_pragma ("GCC", "visibility", handle_pragma_visibility);
102 +#endif
103  
104  #ifdef REGISTER_TARGET_PRAGMAS
105    REGISTER_TARGET_PRAGMAS ();