diff options
Diffstat (limited to 'meta/packages/gcc/gcc-3.4.6/GCC3.4.0VisibilityPatch.diff')
-rw-r--r-- | meta/packages/gcc/gcc-3.4.6/GCC3.4.0VisibilityPatch.diff | 1100 |
1 files changed, 0 insertions, 1100 deletions
diff --git a/meta/packages/gcc/gcc-3.4.6/GCC3.4.0VisibilityPatch.diff b/meta/packages/gcc/gcc-3.4.6/GCC3.4.0VisibilityPatch.diff deleted file mode 100644 index d51da7157d..0000000000 --- a/meta/packages/gcc/gcc-3.4.6/GCC3.4.0VisibilityPatch.diff +++ /dev/null | |||
@@ -1,1100 +0,0 @@ | |||
1 | |||
2 | diff -aur gcc-3.4.0orig/gcc/c-common.c gcc-3.4.0/gcc/c-common.c | ||
3 | --- gcc-3.4.0orig/gcc/c-common.c 2004-03-19 01:32:59.000000000 +0000 | ||
4 | +++ gcc-3.4.0/gcc/c-common.c 2004-05-10 21:05:33.000000000 +0100 | ||
5 | @@ -833,7 +833,7 @@ | ||
6 | handle_deprecated_attribute }, | ||
7 | { "vector_size", 1, 1, false, true, false, | ||
8 | handle_vector_size_attribute }, | ||
9 | - { "visibility", 1, 1, true, false, false, | ||
10 | + { "visibility", 1, 1, false, false, false, | ||
11 | handle_visibility_attribute }, | ||
12 | { "tls_model", 1, 1, true, false, false, | ||
13 | handle_tls_model_attribute }, | ||
14 | @@ -4886,7 +4886,16 @@ | ||
15 | |||
16 | *no_add_attrs = true; | ||
17 | |||
18 | - if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl)) | ||
19 | + if (TYPE_P (*node)) | ||
20 | + { | ||
21 | + if (TREE_CODE (*node) != RECORD_TYPE && TREE_CODE (*node) != UNION_TYPE) | ||
22 | + { | ||
23 | + warning ("`%s' attribute ignored on non-class types", | ||
24 | + IDENTIFIER_POINTER (name)); | ||
25 | + return NULL_TREE; | ||
26 | + } | ||
27 | + } | ||
28 | + else if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl)) | ||
29 | { | ||
30 | warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); | ||
31 | return NULL_TREE; | ||
32 | @@ -4897,6 +4906,14 @@ | ||
33 | error ("visibility arg not a string"); | ||
34 | return NULL_TREE; | ||
35 | } | ||
36 | + | ||
37 | + /* If this is a type, set the visibility on the type decl. */ | ||
38 | + if (TYPE_P (decl)) | ||
39 | + { | ||
40 | + decl = TYPE_NAME (decl); | ||
41 | + if (! decl) | ||
42 | + return NULL_TREE; | ||
43 | + } | ||
44 | |||
45 | if (strcmp (TREE_STRING_POINTER (id), "default") == 0) | ||
46 | DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; | ||
47 | @@ -4908,6 +4925,14 @@ | ||
48 | DECL_VISIBILITY (decl) = VISIBILITY_PROTECTED; | ||
49 | else | ||
50 | error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\""); | ||
51 | + DECL_VISIBILITYSPECIFIED (decl) = 1; | ||
52 | + | ||
53 | + /* For decls only, go ahead and attach the attribute to the node as well. | ||
54 | + This is needed so we can determine whether we have VISIBILITY_DEFAULT | ||
55 | + because the visibility was not specified, or because it was explicitly | ||
56 | + overridden from the class visibility. */ | ||
57 | + if (DECL_P (*node)) | ||
58 | + *no_add_attrs = false; | ||
59 | |||
60 | return NULL_TREE; | ||
61 | } | ||
62 | |||
63 | diff -aur gcc-3.4.0orig/gcc/c-decl.c gcc-3.4.0/gcc/c-decl.c | ||
64 | --- gcc-3.4.0orig/gcc/c-decl.c 2004-03-22 17:58:18.000000000 +0000 | ||
65 | +++ gcc-3.4.0/gcc/c-decl.c 2004-05-10 15:16:27.000000000 +0100 | ||
66 | @@ -1164,9 +1164,8 @@ | ||
67 | } | ||
68 | |||
69 | /* warnings */ | ||
70 | - /* All decls must agree on a non-default visibility. */ | ||
71 | - if (DECL_VISIBILITY (newdecl) != VISIBILITY_DEFAULT | ||
72 | - && DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT | ||
73 | + /* All decls must agree on a visibility. */ | ||
74 | + if (DECL_VISIBILITYSPECIFIED (newdecl) && DECL_VISIBILITYSPECIFIED (olddecl) | ||
75 | && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) | ||
76 | { | ||
77 | warning ("%Jredeclaration of '%D' with different visibility " | ||
78 | @@ -1361,9 +1360,12 @@ | ||
79 | Currently, it can only be defined in the prototype. */ | ||
80 | COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); | ||
81 | |||
82 | - /* If either declaration has a nondefault visibility, use it. */ | ||
83 | - if (DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT) | ||
84 | - DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); | ||
85 | + /* Use visibility of whichever declaration had it specified */ | ||
86 | + if (DECL_VISIBILITYSPECIFIED (olddecl)) | ||
87 | + { | ||
88 | + DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); | ||
89 | + DECL_VISIBILITYSPECIFIED (newdecl) = 1; | ||
90 | + } | ||
91 | |||
92 | if (TREE_CODE (newdecl) == FUNCTION_DECL) | ||
93 | { | ||
94 | |||
95 | diff -aur gcc-3.4.0orig/gcc/common.opt gcc-3.4.0/gcc/common.opt | ||
96 | --- gcc-3.4.0orig/gcc/common.opt 2004-02-18 00:09:04.000000000 +0000 | ||
97 | +++ gcc-3.4.0/gcc/common.opt 2004-05-09 08:10:50.000000000 +0100 | ||
98 | @@ -718,6 +718,11 @@ | ||
99 | Common | ||
100 | Add extra commentary to assembler output | ||
101 | |||
102 | +fvisibility= | ||
103 | +Common Joined RejectNegative | ||
104 | +-fvisibility=[default|internal|hidden|protected] Set the default symbol visibility | ||
105 | + | ||
106 | + | ||
107 | fvpt | ||
108 | Common | ||
109 | Use expression value profiles in optimizations | ||
110 | |||
111 | diff -aur gcc-3.4.0orig/gcc/c.opt gcc-3.4.0/gcc/c.opt | ||
112 | --- gcc-3.4.0orig/gcc/c.opt 2004-02-18 00:09:03.000000000 +0000 | ||
113 | +++ gcc-3.4.0/gcc/c.opt 2004-05-09 08:10:50.000000000 +0100 | ||
114 | @@ -656,6 +656,10 @@ | ||
115 | C++ ObjC++ | ||
116 | Use __cxa_atexit to register destructors | ||
117 | |||
118 | +fvisibility-inlines-hidden | ||
119 | +C++ | ||
120 | +Marks all inlined methods as having hidden visibility | ||
121 | + | ||
122 | fvtable-gc | ||
123 | C++ ObjC++ | ||
124 | Discard unused virtual functions | ||
125 | diff -aur gcc-3.4.0orig/gcc/c-opts.c gcc-3.4.0/gcc/c-opts.c | ||
126 | --- gcc-3.4.0orig/gcc/c-opts.c 2004-02-18 00:09:03.000000000 +0000 | ||
127 | +++ gcc-3.4.0/gcc/c-opts.c 2004-05-09 08:10:50.000000000 +0100 | ||
128 | @@ -912,6 +912,10 @@ | ||
129 | case OPT_fuse_cxa_atexit: | ||
130 | flag_use_cxa_atexit = value; | ||
131 | break; | ||
132 | + | ||
133 | + case OPT_fvisibility_inlines_hidden: | ||
134 | + visibility_options.inlineshidden = value; | ||
135 | + break; | ||
136 | |||
137 | case OPT_fweak: | ||
138 | flag_weak = value; | ||
139 | |||
140 | diff -aur gcc-3.4.0orig/gcc/cp/class.c gcc-3.4.0/gcc/cp/class.c | ||
141 | --- gcc-3.4.0orig/gcc/cp/class.c 2004-03-09 07:27:23.000000000 +0000 | ||
142 | +++ gcc-3.4.0/gcc/cp/class.c 2004-05-10 21:06:50.000000000 +0100 | ||
143 | @@ -524,6 +524,10 @@ | ||
144 | DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node), | ||
145 | DECL_ALIGN (decl)); | ||
146 | |||
147 | + /* The vtable's visibility is the class visibility. There is no way | ||
148 | + to override the visibility for just the vtable. */ | ||
149 | + DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type); | ||
150 | + DECL_VISIBILITYSPECIFIED (decl) = CLASSTYPE_VISIBILITYSPECIFIED (class_type); | ||
151 | import_export_vtable (decl, class_type, 0); | ||
152 | |||
153 | return decl; | ||
154 | @@ -2971,7 +2975,25 @@ | ||
155 | continue; | ||
156 | |||
157 | if (TREE_CODE (x) == CONST_DECL || TREE_CODE (x) == VAR_DECL) | ||
158 | - continue; | ||
159 | + { | ||
160 | + /* Apply the class's visibility attribute to static members | ||
161 | + which do not have a visibility attribute. */ | ||
162 | + if (! lookup_attribute ("visibility", DECL_ATTRIBUTES (x))) | ||
163 | + { | ||
164 | + if (visibility_options.inlineshidden && DECL_INLINE (x)) | ||
165 | + { | ||
166 | + DECL_VISIBILITY (x) = VISIBILITY_HIDDEN; | ||
167 | + DECL_VISIBILITYSPECIFIED (x) = 1; | ||
168 | + } | ||
169 | + else | ||
170 | + { | ||
171 | + DECL_VISIBILITY (x) = CLASSTYPE_VISIBILITY (current_class_type); | ||
172 | + DECL_VISIBILITYSPECIFIED (x) = CLASSTYPE_VISIBILITYSPECIFIED (current_class_type); | ||
173 | + } | ||
174 | + } | ||
175 | + | ||
176 | + continue; | ||
177 | + } | ||
178 | |||
179 | /* Now it can only be a FIELD_DECL. */ | ||
180 | |||
181 | @@ -3708,6 +3730,22 @@ | ||
182 | check_for_override (x, t); | ||
183 | if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x)) | ||
184 | cp_error_at ("initializer specified for non-virtual method `%D'", x); | ||
185 | + | ||
186 | + /* Apply the class's visibility attribute to methods which do | ||
187 | + not have a visibility attribute. */ | ||
188 | + if (! lookup_attribute ("visibility", DECL_ATTRIBUTES (x))) | ||
189 | + { | ||
190 | + if (visibility_options.inlineshidden && DECL_INLINE (x)) | ||
191 | + { | ||
192 | + DECL_VISIBILITY (x) = VISIBILITY_HIDDEN; | ||
193 | + DECL_VISIBILITYSPECIFIED (x) = 1; | ||
194 | + } | ||
195 | + else | ||
196 | + { | ||
197 | + DECL_VISIBILITY (x) = CLASSTYPE_VISIBILITY (current_class_type); | ||
198 | + DECL_VISIBILITYSPECIFIED (x) = CLASSTYPE_VISIBILITYSPECIFIED (current_class_type); | ||
199 | + } | ||
200 | + } | ||
201 | |||
202 | /* The name of the field is the original field name | ||
203 | Save this in auxiliary field for later overloading. */ | ||
204 | @@ -7830,3 +7868,4 @@ | ||
205 | *vid->last_init = build_tree_list (NULL_TREE, init); | ||
206 | vid->last_init = &TREE_CHAIN (*vid->last_init); | ||
207 | } | ||
208 | + | ||
209 | |||
210 | diff -aur gcc-3.4.0orig/gcc/cp/cp-tree.h gcc-3.4.0/gcc/cp/cp-tree.h | ||
211 | --- gcc-3.4.0orig/gcc/cp/cp-tree.h 2004-03-20 00:13:08.000000000 +0000 | ||
212 | +++ gcc-3.4.0/gcc/cp/cp-tree.h 2004-05-10 20:56:56.000000000 +0100 | ||
213 | @@ -1008,7 +1008,12 @@ | ||
214 | #define PUBLICLY_UNIQUELY_DERIVED_P(PARENT, TYPE) \ | ||
215 | (lookup_base ((TYPE), (PARENT), ba_not_special | ba_quiet, NULL) \ | ||
216 | != NULL_TREE) | ||
217 | - | ||
218 | + | ||
219 | +/* Gives the visibility specification for a class type. */ | ||
220 | +#define CLASSTYPE_VISIBILITY(TYPE) DECL_VISIBILITY (TYPE_NAME (TYPE)) | ||
221 | +#define CLASSTYPE_VISIBILITYSPECIFIED(TYPE) DECL_VISIBILITYSPECIFIED (TYPE_NAME (TYPE)) | ||
222 | + | ||
223 | + | ||
224 | /* This is a few header flags for 'struct lang_type'. Actually, | ||
225 | all but the first are used only for lang_type_class; they | ||
226 | are put in this structure to save space. */ | ||
227 | |||
228 | diff -aur gcc-3.4.0orig/gcc/cp/decl.c gcc-3.4.0/gcc/cp/decl.c | ||
229 | --- gcc-3.4.0orig/gcc/cp/decl.c 2004-04-01 21:47:21.000000000 +0100 | ||
230 | +++ gcc-3.4.0/gcc/cp/decl.c 2004-05-28 21:16:11.000000000 +0100 | ||
231 | @@ -1869,17 +1869,34 @@ | ||
232 | DECL_COMMON (newdecl) = DECL_COMMON (olddecl); | ||
233 | COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); | ||
234 | |||
235 | - /* If either declaration has a nondefault visibility, use it. */ | ||
236 | - if (DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT) | ||
237 | + /* Warn about conflicting visibility specifications. */ | ||
238 | + if (DECL_VISIBILITYSPECIFIED (olddecl) && DECL_VISIBILITYSPECIFIED (newdecl) | ||
239 | + && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) | ||
240 | + { | ||
241 | + warning ("%J'%D': visibility attribute ignored because it", | ||
242 | + newdecl, newdecl); | ||
243 | + warning ("%Jconflicts with previous declaration here", olddecl); | ||
244 | + } | ||
245 | + /* Choose the declaration which specified visibility. */ | ||
246 | + if (DECL_VISIBILITYSPECIFIED (olddecl)) | ||
247 | { | ||
248 | - if (DECL_VISIBILITY (newdecl) != VISIBILITY_DEFAULT | ||
249 | - && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) | ||
250 | - { | ||
251 | - warning ("%J'%D': visibility attribute ignored because it", | ||
252 | - newdecl, newdecl); | ||
253 | - warning ("%Jconflicts with previous declaration here", olddecl); | ||
254 | - } | ||
255 | DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); | ||
256 | + DECL_VISIBILITYSPECIFIED (newdecl) = 1; | ||
257 | + } | ||
258 | + /* If it's a definition of a global operator new or operator | ||
259 | + delete, it must be default visibility. */ | ||
260 | + if (NEW_DELETE_OPNAME_P (DECL_NAME (newdecl)) && DECL_INITIAL (newdecl) != NULL_TREE) | ||
261 | + { | ||
262 | + if (!DECL_FUNCTION_MEMBER_P (newdecl) && VISIBILITY_DEFAULT != DECL_VISIBILITY (newdecl)) | ||
263 | + { | ||
264 | + warning ("%J`%D': ignoring non-default symbol", | ||
265 | + newdecl, newdecl); | ||
266 | + warning ("%Jvisibility on global operator new or delete", newdecl); | ||
267 | + DECL_VISIBILITY (olddecl) = VISIBILITY_DEFAULT; | ||
268 | + DECL_VISIBILITYSPECIFIED (olddecl) = 1; | ||
269 | + DECL_VISIBILITY (newdecl) = VISIBILITY_DEFAULT; | ||
270 | + DECL_VISIBILITYSPECIFIED (newdecl) = 1; | ||
271 | + } | ||
272 | } | ||
273 | |||
274 | if (TREE_CODE (newdecl) == FUNCTION_DECL) | ||
275 | |||
276 | diff -aur gcc-3.4.0orig/gcc/cp/method.c gcc-3.4.0/gcc/cp/method.c | ||
277 | --- gcc-3.4.0orig/gcc/cp/method.c 2004-04-08 23:15:58.000000000 +0100 | ||
278 | +++ gcc-3.4.0/gcc/cp/method.c 2004-05-09 08:10:52.000000000 +0100 | ||
279 | @@ -394,6 +394,7 @@ | ||
280 | rewrite. */ | ||
281 | TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function); | ||
282 | DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function); | ||
283 | + DECL_VISIBILITYSPECIFIED (thunk_fndecl) = DECL_VISIBILITYSPECIFIED (function); | ||
284 | |||
285 | if (flag_syntax_only) | ||
286 | { | ||
287 | |||
288 | diff -aur gcc-3.4.0orig/gcc/cp/optimize.c gcc-3.4.0/gcc/cp/optimize.c | ||
289 | --- gcc-3.4.0orig/gcc/cp/optimize.c 2004-02-08 01:52:50.000000000 +0000 | ||
290 | +++ gcc-3.4.0/gcc/cp/optimize.c 2004-05-09 08:10:52.000000000 +0100 | ||
291 | @@ -155,6 +155,7 @@ | ||
292 | DECL_NOT_REALLY_EXTERN (clone) = DECL_NOT_REALLY_EXTERN (fn); | ||
293 | TREE_PUBLIC (clone) = TREE_PUBLIC (fn); | ||
294 | DECL_VISIBILITY (clone) = DECL_VISIBILITY (fn); | ||
295 | + DECL_VISIBILITYSPECIFIED (clone) = DECL_VISIBILITYSPECIFIED (fn); | ||
296 | |||
297 | /* Adjust the parameter names and locations. */ | ||
298 | parm = DECL_ARGUMENTS (fn); | ||
299 | |||
300 | diff -aur gcc-3.4.0orig/gcc/cp/rtti.c gcc-3.4.0/gcc/cp/rtti.c | ||
301 | --- gcc-3.4.0orig/gcc/cp/rtti.c 2004-03-08 23:00:26.000000000 +0000 | ||
302 | +++ gcc-3.4.0/gcc/cp/rtti.c 2004-05-10 21:09:21.000000000 +0100 | ||
303 | @@ -361,7 +361,11 @@ | ||
304 | pushdecl_top_level_and_finish (d, NULL_TREE); | ||
305 | |||
306 | if (CLASS_TYPE_P (type)) | ||
307 | - CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d; | ||
308 | + { | ||
309 | + CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d; | ||
310 | + DECL_VISIBILITY (d) = CLASSTYPE_VISIBILITY (type); | ||
311 | + DECL_VISIBILITYSPECIFIED (d) = CLASSTYPE_VISIBILITYSPECIFIED (type); | ||
312 | + } | ||
313 | |||
314 | /* Remember the type it is for. */ | ||
315 | TREE_TYPE (name) = type; | ||
316 | @@ -759,6 +763,11 @@ | ||
317 | TREE_STATIC (name_decl) = 1; | ||
318 | DECL_EXTERNAL (name_decl) = 0; | ||
319 | TREE_PUBLIC (name_decl) = 1; | ||
320 | + if (CLASS_TYPE_P (target)) | ||
321 | + { | ||
322 | + DECL_VISIBILITY (name_decl) = CLASSTYPE_VISIBILITY (target); | ||
323 | + DECL_VISIBILITYSPECIFIED (name_decl) = CLASSTYPE_VISIBILITYSPECIFIED (target); | ||
324 | + } | ||
325 | import_export_tinfo (name_decl, target, typeinfo_in_lib_p (target)); | ||
326 | /* External name of the string containing the type's name has a | ||
327 | special name. */ | ||
328 | |||
329 | diff -aur gcc-3.4.0orig/gcc/c-pragma.c gcc-3.4.0/gcc/c-pragma.c | ||
330 | --- gcc-3.4.0orig/gcc/c-pragma.c 2004-01-23 23:35:53.000000000 +0000 | ||
331 | +++ gcc-3.4.0/gcc/c-pragma.c 2004-05-09 08:10:52.000000000 +0100 | ||
332 | @@ -480,6 +480,86 @@ | ||
333 | return asmname; | ||
334 | } | ||
335 | |||
336 | + | ||
337 | +#ifdef HANDLE_PRAGMA_VISIBILITY | ||
338 | +static void handle_pragma_visibility (cpp_reader *); | ||
339 | + | ||
340 | +/* Sets the default visibility for symbols to something other than that | ||
341 | + specified on the command line. */ | ||
342 | +static void | ||
343 | +handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) | ||
344 | +{ /* Form is #pragma GCC visibility push(hidden)|pop */ | ||
345 | + static int visstack [16], visidx; | ||
346 | + tree x; | ||
347 | + enum cpp_ttype token; | ||
348 | + enum { bad, push, pop } action = bad; | ||
349 | + | ||
350 | + token = c_lex (&x); | ||
351 | + if (token == CPP_NAME) | ||
352 | + { | ||
353 | + const char *op = IDENTIFIER_POINTER (x); | ||
354 | + if (!strcmp (op, "push")) | ||
355 | + action = push; | ||
356 | + else if (!strcmp (op, "pop")) | ||
357 | + action = pop; | ||
358 | + } | ||
359 | + if (bad == action) | ||
360 | + GCC_BAD ("#pragma GCC visibility must be followed by push or pop"); | ||
361 | + else | ||
362 | + { | ||
363 | + if (pop == action) | ||
364 | + { | ||
365 | + if (!visidx) | ||
366 | + { | ||
367 | + GCC_BAD ("No matching push for '#pragma GCC visibility pop'"); | ||
368 | + } | ||
369 | + else | ||
370 | + { | ||
371 | + default_visibility = visstack[--visidx]; | ||
372 | + visibility_options.inpragma = (visidx>0); | ||
373 | + } | ||
374 | + } | ||
375 | + else | ||
376 | + { | ||
377 | + if (c_lex (&x) != CPP_OPEN_PAREN) | ||
378 | + GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored"); | ||
379 | + token = c_lex (&x); | ||
380 | + if (token != CPP_NAME) | ||
381 | + { | ||
382 | + GCC_BAD ("malformed #pragma GCC visibility push"); | ||
383 | + } | ||
384 | + else if (visidx >= 16) | ||
385 | + { | ||
386 | + GCC_BAD ("No more than sixteen #pragma GCC visibility pushes allowed at once"); | ||
387 | + } | ||
388 | + else | ||
389 | + { | ||
390 | + const char *str = IDENTIFIER_POINTER (x); | ||
391 | + visstack[visidx++] = default_visibility; | ||
392 | + if (!strcmp (str, "default")) | ||
393 | + default_visibility = VISIBILITY_DEFAULT; | ||
394 | + else if (!strcmp (str, "internal")) | ||
395 | + default_visibility = VISIBILITY_INTERNAL; | ||
396 | + else if (!strcmp (str, "hidden")) | ||
397 | + default_visibility = VISIBILITY_HIDDEN; | ||
398 | + else if (!strcmp (str, "protected")) | ||
399 | + default_visibility = VISIBILITY_PROTECTED; | ||
400 | + else | ||
401 | + { | ||
402 | + GCC_BAD ("#pragma GCC visibility push() must specify default, internal, hidden or protected"); | ||
403 | + } | ||
404 | + visibility_options.inpragma = 1; | ||
405 | + } | ||
406 | + if (c_lex (&x) != CPP_CLOSE_PAREN) | ||
407 | + GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored"); | ||
408 | + } | ||
409 | + } | ||
410 | + if (c_lex (&x) != CPP_EOF) | ||
411 | + warning ("junk at end of '#pragma GCC visibility'"); | ||
412 | +} | ||
413 | + | ||
414 | +#endif | ||
415 | + | ||
416 | /* Front-end wrapper for pragma registration to avoid dragging | ||
417 | cpplib.h in almost everywhere. */ | ||
418 | void | ||
419 | @@ -505,6 +585,9 @@ | ||
420 | #ifdef HANDLE_PRAGMA_EXTERN_PREFIX | ||
421 | c_register_pragma (0, "extern_prefix", handle_pragma_extern_prefix); | ||
422 | #endif | ||
423 | +#ifdef HANDLE_PRAGMA_VISIBILITY | ||
424 | + c_register_pragma ("GCC", "visibility", handle_pragma_visibility); | ||
425 | +#endif | ||
426 | |||
427 | #ifdef REGISTER_TARGET_PRAGMAS | ||
428 | REGISTER_TARGET_PRAGMAS (); | ||
429 | diff -aur gcc-3.4.0orig/gcc/c-pragma.h gcc-3.4.0/gcc/c-pragma.h | ||
430 | --- gcc-3.4.0orig/gcc/c-pragma.h 2004-01-31 06:18:05.000000000 +0000 | ||
431 | +++ gcc-3.4.0/gcc/c-pragma.h 2004-05-09 08:10:53.000000000 +0100 | ||
432 | @@ -44,6 +44,11 @@ | ||
433 | #define HANDLE_PRAGMA_PACK 1 | ||
434 | #endif /* HANDLE_PRAGMA_PACK_PUSH_POP */ | ||
435 | |||
436 | +/* It's safe to always leave visibility pragma enabled as if | ||
437 | + visibility is not supported on the host OS platform the | ||
438 | + statements are ignored. */ | ||
439 | +#define HANDLE_PRAGMA_VISIBILITY 1 | ||
440 | + | ||
441 | extern void init_pragma (void); | ||
442 | |||
443 | /* Front-end wrapper for pragma registration to avoid dragging | ||
444 | |||
445 | |||
446 | diff -aur gcc-3.4.0orig/gcc/doc/invoke.texi gcc-3.4.0/gcc/doc/invoke.texi | ||
447 | --- gcc-3.4.0orig/gcc/doc/invoke.texi 2004-04-19 00:05:36.000000000 +0100 | ||
448 | +++ gcc-3.4.0/gcc/doc/invoke.texi 2004-05-28 21:29:36.000000000 +0100 | ||
449 | @@ -183,7 +183,8 @@ | ||
450 | -fno-optional-diags -fpermissive @gol | ||
451 | -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol | ||
452 | -fuse-cxa-atexit -fno-weak -nostdinc++ @gol | ||
453 | --fno-default-inline -Wabi -Wctor-dtor-privacy @gol | ||
454 | +-fno-default-inline -fvisibility-inlines-hidden @gol | ||
455 | +-Wabi -Wctor-dtor-privacy @gol | ||
456 | -Wnon-virtual-dtor -Wreorder @gol | ||
457 | -Weffc++ -Wno-deprecated @gol | ||
458 | -Wno-non-template-friend -Wold-style-cast @gol | ||
459 | @@ -674,7 +675,8 @@ | ||
460 | -fargument-alias -fargument-noalias @gol | ||
461 | -fargument-noalias-global -fleading-underscore @gol | ||
462 | -ftls-model=@var{model} @gol | ||
463 | --ftrapv -fwrapv -fbounds-check} | ||
464 | +-ftrapv -fwrapv -fbounds-check @gol | ||
465 | +-fvisibility} | ||
466 | @end table | ||
467 | |||
468 | @menu | ||
469 | @@ -1433,6 +1435,20 @@ | ||
470 | destructors, but will only work if your C library supports | ||
471 | @code{__cxa_atexit}. | ||
472 | |||
473 | +@item -fvisibility-inlines-hidden | ||
474 | +@opindex fvisibility-inlines-hidden | ||
475 | +Causes all inlined methods to be marked with | ||
476 | +@code{__attribute__ ((visibility ("hidden")))} so that they do not | ||
477 | +appear in the export table of a DSO and do not require a PLT indirection | ||
478 | +when used within the DSO. Enabling this option can have a dramatic effect | ||
479 | +on load and link times of a DSO as it massively reduces the size of the | ||
480 | +dynamic export table when the library makes heavy use of templates. While | ||
481 | +it can cause bloating through duplication of code within each DSO where | ||
482 | +it is used, often the wastage is less than the considerable space occupied | ||
483 | +by a long symbol name in the export table which is typical when using | ||
484 | +templates and namespaces. For even more savings, combine with the | ||
485 | +@code{-fvisibility=hidden} switch. | ||
486 | + | ||
487 | @item -fno-weak | ||
488 | @opindex fno-weak | ||
489 | Do not use weak symbol support, even if it is provided by the linker. | ||
490 | @@ -11198,6 +11214,54 @@ | ||
491 | |||
492 | The default without @option{-fpic} is @code{initial-exec}; with | ||
493 | @option{-fpic} the default is @code{global-dynamic}. | ||
494 | + | ||
495 | +@item -fvisibility=@var{default|internal|hidden|protected} | ||
496 | +@opindex fvisibility | ||
497 | +Set the default ELF image symbol visibility to the specified option - all | ||
498 | +symbols will be marked with this unless overrided within the code. | ||
499 | +Using this feature can very substantially improve linking and | ||
500 | +load times of shared object libraries, produce more optimised | ||
501 | +code, provide near-perfect API export and prevent symbol clashes. | ||
502 | +It is @strong{strongly} recommended that you use this in any shared objects | ||
503 | +you distribute. | ||
504 | + | ||
505 | +Despite the nomenclature, @code{default} always means public ie; | ||
506 | +available to be linked against from outside the shared object. | ||
507 | +@code{protected} and @code{internal} are pretty useless in real-world | ||
508 | +usage so the only other commonly used option will be @code{hidden}. | ||
509 | +The default if -fvisibility isn't specified is @code{default} ie; make every | ||
510 | +symbol public - this causes the same behaviour as previous versions of | ||
511 | +GCC. | ||
512 | + | ||
513 | +A good explanation of the benefits offered by ensuring ELF | ||
514 | +symbols have the correct visibility is given by ``How To Write | ||
515 | +Shared Libraries'' by Ulrich Drepper (which can be found at | ||
516 | +@w{@uref{http://people.redhat.com/~drepper/}}) - however a superior | ||
517 | +solution made possible by this option to marking things hidden when | ||
518 | +the default is public is to make the default hidden and mark things | ||
519 | +public. This is the norm with DLL's on Windows and with @option{-fvisibility=hidden} | ||
520 | +and @code{__attribute__ ((visibility("default")))} instead of | ||
521 | +@code{__declspec(dllexport)} you get almost identical semantics with | ||
522 | +identical syntax. This is a great boon to those working with | ||
523 | +cross-platform projects. | ||
524 | + | ||
525 | +For those adding visibility support to existing code, you may find | ||
526 | +@samp{#pragma GCC visibility} of use. This works by you enclosing | ||
527 | +the declarations you wish to set visibility for with (for example) | ||
528 | +@samp{#pragma GCC visibility push(hidden)} and | ||
529 | +@samp{#pragma GCC visibility pop}. These can be nested up to sixteen | ||
530 | +times. Bear in mind that symbol visibility should be viewed @strong{as | ||
531 | +part of the API interface contract} and thus all new code should | ||
532 | +always specify visibility when it is not the default ie; declarations | ||
533 | +only for use within the local DSO should @strong{always} be marked explicitly | ||
534 | +as hidden as so to avoid PLT indirection overheads - making this | ||
535 | +abundantly clear also aids readability and self-documentation of the code. | ||
536 | +Note that due to ISO C++ specification requirements, operator new and | ||
537 | +operator delete must always be of default visibility. | ||
538 | + | ||
539 | +An overview of these techniques, their benefits and how to use them | ||
540 | +is at @w{@uref{http://www.nedprod.com/programs/gccvisibility.html}}. | ||
541 | + | ||
542 | @end table | ||
543 | |||
544 | @c man end | ||
545 | |||
546 | diff -aur gcc-3.4.0orig/gcc/flags.h gcc-3.4.0/gcc/flags.h | ||
547 | --- gcc-3.4.0orig/gcc/flags.h 2004-02-18 00:09:04.000000000 +0000 | ||
548 | +++ gcc-3.4.0/gcc/flags.h 2004-05-09 08:10:53.000000000 +0100 | ||
549 | @@ -60,6 +60,30 @@ | ||
550 | /* Nonzero means emit debugging information only for symbols which are used. */ | ||
551 | extern int flag_debug_only_used_symbols; | ||
552 | |||
553 | +/* Enumerate visibility settings. */ | ||
554 | +#ifndef SYMBOL_VISIBILITY_DEFINED | ||
555 | +#define SYMBOL_VISIBILITY_DEFINED | ||
556 | +enum symbol_visibility | ||
557 | +{ | ||
558 | + VISIBILITY_DEFAULT, | ||
559 | + VISIBILITY_INTERNAL, | ||
560 | + VISIBILITY_HIDDEN, | ||
561 | + VISIBILITY_PROTECTED | ||
562 | +}; | ||
563 | +#endif | ||
564 | + | ||
565 | +/* The default visibility for all symbols (unless overridden). */ | ||
566 | +extern enum symbol_visibility default_visibility; | ||
567 | + | ||
568 | +struct visibility_flags | ||
569 | +{ | ||
570 | + unsigned inpragma : 1; /* True when in #pragma GCC visibility. */ | ||
571 | + unsigned inlineshidden : 1; /* True when -finlineshidden in effect. */ | ||
572 | +}; | ||
573 | + | ||
574 | +/* Global visibility options. */ | ||
575 | +extern struct visibility_flags visibility_options; | ||
576 | + | ||
577 | /* Nonzero means do optimizations. -opt. */ | ||
578 | |||
579 | extern int optimize; | ||
580 | |||
581 | diff -aur gcc-3.4.0orig/gcc/opts.c gcc-3.4.0/gcc/opts.c | ||
582 | --- gcc-3.4.0orig/gcc/opts.c 2004-02-18 00:09:04.000000000 +0000 | ||
583 | +++ gcc-3.4.0/gcc/opts.c 2004-05-09 08:10:53.000000000 +0100 | ||
584 | @@ -142,6 +142,12 @@ | ||
585 | write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ | ||
586 | bool use_gnu_debug_info_extensions; | ||
587 | |||
588 | +/* The default visibility for all symbols (unless overridden) */ | ||
589 | +enum symbol_visibility default_visibility = VISIBILITY_DEFAULT; | ||
590 | + | ||
591 | +/* Global visibility options. */ | ||
592 | +struct visibility_flags visibility_options; | ||
593 | + | ||
594 | /* Columns of --help display. */ | ||
595 | static unsigned int columns = 80; | ||
596 | |||
597 | @@ -1440,6 +1446,21 @@ | ||
598 | flag_verbose_asm = value; | ||
599 | break; | ||
600 | |||
601 | + case OPT_fvisibility_: | ||
602 | + { | ||
603 | + if(!strcmp(arg, "default")) | ||
604 | + default_visibility=VISIBILITY_DEFAULT; | ||
605 | + else if(!strcmp(arg, "internal")) | ||
606 | + default_visibility=VISIBILITY_INTERNAL; | ||
607 | + else if(!strcmp(arg, "hidden")) | ||
608 | + default_visibility=VISIBILITY_HIDDEN; | ||
609 | + else if(!strcmp(arg, "protected")) | ||
610 | + default_visibility=VISIBILITY_PROTECTED; | ||
611 | + else | ||
612 | + error("unrecognised visibility value \"%s\"", arg); | ||
613 | + } | ||
614 | + break; | ||
615 | + | ||
616 | case OPT_fweb: | ||
617 | flag_web = value; | ||
618 | break; | ||
619 | |||
620 | diff -aur gcc-3.4.0orig/gcc/tree.c gcc-3.4.0/gcc/tree.c | ||
621 | --- gcc-3.4.0orig/gcc/tree.c 2004-02-05 22:01:35.000000000 +0000 | ||
622 | +++ gcc-3.4.0/gcc/tree.c 2004-05-10 15:22:52.000000000 +0100 | ||
623 | @@ -2563,6 +2563,11 @@ | ||
624 | layout_decl (t, 0); | ||
625 | else if (code == FUNCTION_DECL) | ||
626 | DECL_MODE (t) = FUNCTION_MODE; | ||
627 | + | ||
628 | + /* Set default visibility to whatever the user supplied with | ||
629 | + visibility_specified depending on #pragma GCC visibility. */ | ||
630 | + DECL_VISIBILITY (t) = default_visibility; | ||
631 | + DECL_VISIBILITYSPECIFIED (t) = visibility_options.inpragma; | ||
632 | |||
633 | return t; | ||
634 | } | ||
635 | |||
636 | diff -aur gcc-3.4.0orig/gcc/tree.h gcc-3.4.0/gcc/tree.h | ||
637 | --- gcc-3.4.0orig/gcc/tree.h 2004-02-08 01:52:43.000000000 +0000 | ||
638 | +++ gcc-3.4.0/gcc/tree.h 2004-05-09 08:10:54.000000000 +0100 | ||
639 | @@ -1499,6 +1499,10 @@ | ||
640 | /* Value of the decls's visibility attribute */ | ||
641 | #define DECL_VISIBILITY(NODE) (DECL_CHECK (NODE)->decl.visibility) | ||
642 | |||
643 | +/* Nonzero means that the decl had its visibility specified rather than | ||
644 | + being inferred. */ | ||
645 | +#define DECL_VISIBILITYSPECIFIED(NODE) (DECL_CHECK (NODE)->decl.visibility_specified) | ||
646 | + | ||
647 | /* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */ | ||
648 | #define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable) | ||
649 | |||
650 | @@ -1633,7 +1637,8 @@ | ||
651 | || TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL) | ||
652 | |||
653 | /* Enumerate visibility settings. */ | ||
654 | - | ||
655 | +#ifndef SYMBOL_VISIBILITY_DEFINED | ||
656 | +#define SYMBOL_VISIBILITY_DEFINED | ||
657 | enum symbol_visibility | ||
658 | { | ||
659 | VISIBILITY_DEFAULT, | ||
660 | @@ -1641,6 +1646,7 @@ | ||
661 | VISIBILITY_HIDDEN, | ||
662 | VISIBILITY_PROTECTED | ||
663 | }; | ||
664 | +#endif | ||
665 | |||
666 | struct function; | ||
667 | |||
668 | @@ -1684,8 +1690,7 @@ | ||
669 | unsigned thread_local_flag : 1; | ||
670 | unsigned declared_inline_flag : 1; | ||
671 | ENUM_BITFIELD(symbol_visibility) visibility : 2; | ||
672 | - unsigned unused : 1; | ||
673 | - /* one unused bit. */ | ||
674 | + unsigned visibility_specified : 1; | ||
675 | |||
676 | unsigned lang_flag_0 : 1; | ||
677 | unsigned lang_flag_1 : 1; | ||
678 | |||
679 | diff -aur gcc-3.4.0orig/gcc/varasm.c gcc-3.4.0/gcc/varasm.c | ||
680 | --- gcc-3.4.0orig/gcc/varasm.c 2004-04-14 22:14:08.000000000 +0100 | ||
681 | +++ gcc-3.4.0/gcc/varasm.c 2004-05-09 08:10:54.000000000 +0100 | ||
682 | @@ -5150,8 +5150,8 @@ | ||
683 | /* Static variables are always local. */ | ||
684 | else if (! TREE_PUBLIC (exp)) | ||
685 | local_p = true; | ||
686 | - /* A variable is local if the user tells us so. */ | ||
687 | - else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) | ||
688 | + /* A variable is local if the user explicitly tells us so. */ | ||
689 | + else if (DECL_VISIBILITYSPECIFIED (exp) && DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) | ||
690 | local_p = true; | ||
691 | /* Otherwise, variables defined outside this object may not be local. */ | ||
692 | else if (DECL_EXTERNAL (exp)) | ||
693 | @@ -5159,6 +5159,9 @@ | ||
694 | /* Linkonce and weak data are never local. */ | ||
695 | else if (DECL_ONE_ONLY (exp) || DECL_WEAK (exp)) | ||
696 | local_p = false; | ||
697 | + /* If none of the above and visibility is not default, make local. */ | ||
698 | + else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT) | ||
699 | + local_p = true; | ||
700 | /* If PIC, then assume that any global name can be overridden by | ||
701 | symbols resolved from other modules. */ | ||
702 | else if (shlib) | ||
703 | |||
704 | diff -Naur gcc-3.4.0orig/gcc/testsuite/gcc.dg/visibility-9.c gcc-3.4.0/gcc/testsuite/gcc.dg/visibility-9.c | ||
705 | --- gcc-3.4.0orig/gcc/testsuite/gcc.dg/visibility-9.c 1970-01-01 01:00:00.000000000 +0100 | ||
706 | +++ gcc-3.4.0/gcc/testsuite/gcc.dg/visibility-9.c 2004-05-09 12:40:39.000000000 +0100 | ||
707 | @@ -0,0 +1,9 @@ | ||
708 | +/* Test that -fvisibility works. */ | ||
709 | +/* { dg-do compile } */ | ||
710 | +/* { dg-require-visibility "" } */ | ||
711 | +/* { dg-options "-fvisibility=hidden" } */ | ||
712 | +/* { dg-final { scan-assembler "\\.hidden.*foo" } } */ | ||
713 | + | ||
714 | +void foo(); | ||
715 | + | ||
716 | +void foo() { } | ||
717 | diff -Naur gcc-3.4.0orig/gcc/testsuite/gcc.dg/visibility-a.c gcc-3.4.0/gcc/testsuite/gcc.dg/visibility-a.c | ||
718 | --- gcc-3.4.0orig/gcc/testsuite/gcc.dg/visibility-a.c 1970-01-01 01:00:00.000000000 +0100 | ||
719 | +++ gcc-3.4.0/gcc/testsuite/gcc.dg/visibility-a.c 2004-05-09 12:55:04.000000000 +0100 | ||
720 | @@ -0,0 +1,10 @@ | ||
721 | +/* Test that #pragma GCC visibility works. */ | ||
722 | +/* { dg-do compile } */ | ||
723 | +/* { dg-require-visibility "" } */ | ||
724 | +/* { dg-final { scan-assembler "\\.hidden.*foo" } } */ | ||
725 | + | ||
726 | +#pragma GCC visibility push(hidden) | ||
727 | +void foo(); | ||
728 | +#pragma GCC visibility pop | ||
729 | + | ||
730 | +void foo() { } | ||
731 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C | ||
732 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C 1970-01-01 01:00:00.000000000 +0100 | ||
733 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C 2004-05-09 19:17:13.000000000 +0100 | ||
734 | @@ -0,0 +1,12 @@ | ||
735 | +/* Test that -fvisibility affects class members. */ | ||
736 | +/* { dg-do compile } */ | ||
737 | +/* { dg-require-visibility "" } */ | ||
738 | +/* { dg-options "-fvisibility=hidden" } */ | ||
739 | +/* { dg-final { scan-assembler "\\.hidden.*Foo.methodEv" } } */ | ||
740 | + | ||
741 | +class Foo | ||
742 | +{ | ||
743 | + void method(); | ||
744 | +}; | ||
745 | + | ||
746 | +void Foo::method() { } | ||
747 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C | ||
748 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C 1970-01-01 01:00:00.000000000 +0100 | ||
749 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C 2004-05-09 19:17:59.000000000 +0100 | ||
750 | @@ -0,0 +1,18 @@ | ||
751 | +/* Test that -fvisibility-inlines-hidden affects class members. */ | ||
752 | +/* { dg-do compile } */ | ||
753 | +/* { dg-require-visibility "" } */ | ||
754 | +/* { dg-options "-fvisibility-inlines-hidden" } */ | ||
755 | +/* { dg-final { scan-assembler "\\.hidden.*Foo.methodEv" } } */ | ||
756 | + | ||
757 | +class Foo | ||
758 | +{ | ||
759 | +public: | ||
760 | + void method() { } | ||
761 | +}; | ||
762 | + | ||
763 | +int main(void) | ||
764 | +{ | ||
765 | + Foo f; | ||
766 | + f.method(); | ||
767 | + return 0; | ||
768 | +} | ||
769 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C | ||
770 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C 1970-01-01 01:00:00.000000000 +0100 | ||
771 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C 2004-05-09 19:18:06.000000000 +0100 | ||
772 | @@ -0,0 +1,12 @@ | ||
773 | +/* Test that -fvisibility does not override class member specific settings. */ | ||
774 | +/* { dg-do compile } */ | ||
775 | +/* { dg-require-visibility "" } */ | ||
776 | +/* { dg-options "-fvisibility=hidden" } */ | ||
777 | +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */ | ||
778 | + | ||
779 | +class __attribute__ ((visibility ("internal"))) Foo | ||
780 | +{ | ||
781 | + void method(); | ||
782 | +}; | ||
783 | + | ||
784 | +void Foo::method() { } | ||
785 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C | ||
786 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C 1970-01-01 01:00:00.000000000 +0100 | ||
787 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C 2004-05-09 19:18:12.000000000 +0100 | ||
788 | @@ -0,0 +1,12 @@ | ||
789 | +/* Test that -fvisibility does not override class member specific settings. */ | ||
790 | +/* { dg-do compile } */ | ||
791 | +/* { dg-require-visibility "" } */ | ||
792 | +/* { dg-options "-fvisibility=hidden" } */ | ||
793 | +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */ | ||
794 | + | ||
795 | +class Foo | ||
796 | +{ | ||
797 | + __attribute__ ((visibility ("internal"))) void method(); | ||
798 | +}; | ||
799 | + | ||
800 | +void Foo::method() { } | ||
801 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C | ||
802 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C 1970-01-01 01:00:00.000000000 +0100 | ||
803 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C 2004-05-09 19:18:19.000000000 +0100 | ||
804 | @@ -0,0 +1,11 @@ | ||
805 | +/* Test that setting visibility for class member functions works. */ | ||
806 | +/* { dg-do compile } */ | ||
807 | +/* { dg-require-visibility "" } */ | ||
808 | +/* { dg-final { scan-assembler "\\.hidden.*Foo.methodEv" } } */ | ||
809 | + | ||
810 | +class __attribute__ ((visibility ("hidden"))) Foo | ||
811 | +{ | ||
812 | + void method(); | ||
813 | +}; | ||
814 | + | ||
815 | +void Foo::method() { } | ||
816 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/noPLT.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/noPLT.C | ||
817 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/noPLT.C 1970-01-01 01:00:00.000000000 +0100 | ||
818 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/noPLT.C 2004-05-09 19:21:49.000000000 +0100 | ||
819 | @@ -0,0 +1,20 @@ | ||
820 | +/* Test that -fvisibility=hidden prevents PLT. */ | ||
821 | +/* { dg-do compile } */ | ||
822 | +/* { dg-require-visibility "" } */ | ||
823 | +/* { dg-options "-fPIC -fvisibility=hidden" } */ | ||
824 | +/* { dg-final { scan-assembler-not "methodEv@PLT" } } */ | ||
825 | + | ||
826 | +class Foo | ||
827 | +{ | ||
828 | +public: | ||
829 | + void method(); | ||
830 | +}; | ||
831 | + | ||
832 | +void Foo::method() { } | ||
833 | + | ||
834 | +int main(void) | ||
835 | +{ | ||
836 | + Foo f; | ||
837 | + f.method(); | ||
838 | + return 0; | ||
839 | +} | ||
840 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma.C | ||
841 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma.C 1970-01-01 01:00:00.000000000 +0100 | ||
842 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma.C 2004-05-09 19:18:30.000000000 +0100 | ||
843 | @@ -0,0 +1,13 @@ | ||
844 | +/* Test that #pragma GCC visibility affects class members. */ | ||
845 | +/* { dg-do compile } */ | ||
846 | +/* { dg-require-visibility "" } */ | ||
847 | +/* { dg-final { scan-assembler "\\.hidden.*Foo.methodEv" } } */ | ||
848 | + | ||
849 | +#pragma GCC visibility push(hidden) | ||
850 | +class Foo | ||
851 | +{ | ||
852 | + void method(); | ||
853 | +}; | ||
854 | +#pragma GCC visibility pop | ||
855 | + | ||
856 | +void Foo::method() { } | ||
857 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C | ||
858 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C 1970-01-01 01:00:00.000000000 +0100 | ||
859 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C 2004-05-09 19:18:36.000000000 +0100 | ||
860 | @@ -0,0 +1,13 @@ | ||
861 | +/* Test that #pragma GCC visibility does not override class member specific settings. */ | ||
862 | +/* { dg-do compile } */ | ||
863 | +/* { dg-require-visibility "" } */ | ||
864 | +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */ | ||
865 | + | ||
866 | +#pragma GCC visibility push(hidden) | ||
867 | +class __attribute__ ((visibility ("internal"))) Foo | ||
868 | +{ | ||
869 | + void method(); | ||
870 | +}; | ||
871 | +#pragma GCC visibility pop | ||
872 | + | ||
873 | +void Foo::method() { } | ||
874 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C | ||
875 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C 1970-01-01 01:00:00.000000000 +0100 | ||
876 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C 2004-05-09 19:18:44.000000000 +0100 | ||
877 | @@ -0,0 +1,13 @@ | ||
878 | +/* Test that #pragma GCC visibility does not override class member specific settings. */ | ||
879 | +/* { dg-do compile } */ | ||
880 | +/* { dg-require-visibility "" } */ | ||
881 | +/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */ | ||
882 | + | ||
883 | +#pragma GCC visibility push(hidden) | ||
884 | +class Foo | ||
885 | +{ | ||
886 | + __attribute__ ((visibility ("internal"))) void method(); | ||
887 | +}; | ||
888 | +#pragma GCC visibility pop | ||
889 | + | ||
890 | +void Foo::method() { } | ||
891 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C | ||
892 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C 1970-01-01 01:00:00.000000000 +0100 | ||
893 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C 2004-05-09 19:18:50.000000000 +0100 | ||
894 | @@ -0,0 +1,11 @@ | ||
895 | +/* Test that setting visibility for static class member functions works. */ | ||
896 | +/* { dg-do compile } */ | ||
897 | +/* { dg-require-visibility "" } */ | ||
898 | +/* { dg-final { scan-assembler "\\.hidden.*Foo.methodEv" } } */ | ||
899 | + | ||
900 | +class __attribute__ ((visibility ("hidden"))) Foo | ||
901 | +{ | ||
902 | + static void method(); | ||
903 | +}; | ||
904 | + | ||
905 | +void Foo::method() { } | ||
906 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/virtual.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/virtual.C | ||
907 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/virtual.C 1970-01-01 01:00:00.000000000 +0100 | ||
908 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/virtual.C 2004-05-09 13:24:06.000000000 +0100 | ||
909 | @@ -0,0 +1,11 @@ | ||
910 | +/* Test that setting visibility for class affects virtual table. */ | ||
911 | +/* { dg-do compile } */ | ||
912 | +/* { dg-require-visibility "" } */ | ||
913 | +/* { dg-final { scan-assembler "\\.hidden.*ZTV3Foo" } } */ | ||
914 | + | ||
915 | +class __attribute__ ((visibility ("hidden"))) Foo | ||
916 | +{ | ||
917 | + virtual void method(); | ||
918 | +}; | ||
919 | + | ||
920 | +void Foo::method() { } | ||
921 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C | ||
922 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C 1970-01-01 01:00:00.000000000 +0100 | ||
923 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C 2003-12-10 06:34:44.000000000 +0000 | ||
924 | @@ -0,0 +1,8 @@ | ||
925 | +/* Test visibility attribute on function definition. */ | ||
926 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
927 | +/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
928 | + | ||
929 | +void | ||
930 | +__attribute__((visibility ("hidden"))) | ||
931 | +foo() | ||
932 | +{ } | ||
933 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C | ||
934 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C 1970-01-01 01:00:00.000000000 +0100 | ||
935 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C 2003-12-10 06:34:44.000000000 +0000 | ||
936 | @@ -0,0 +1,7 @@ | ||
937 | +/* Test that visibility attribute on declaration extends to definition. */ | ||
938 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
939 | +/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
940 | + | ||
941 | +void __attribute__((visibility ("hidden"))) foo(); | ||
942 | + | ||
943 | +void foo() { } | ||
944 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C | ||
945 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C 1970-01-01 01:00:00.000000000 +0100 | ||
946 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C 2003-12-10 06:34:45.000000000 +0000 | ||
947 | @@ -0,0 +1,7 @@ | ||
948 | +/* Test visibility attribute on forward declaration of global variable */ | ||
949 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
950 | +/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
951 | + | ||
952 | +int | ||
953 | +__attribute__((visibility ("hidden"))) | ||
954 | +xyzzy = 5; | ||
955 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C | ||
956 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C 1970-01-01 01:00:00.000000000 +0100 | ||
957 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C 2003-12-10 06:34:45.000000000 +0000 | ||
958 | @@ -0,0 +1,8 @@ | ||
959 | +/* Test visibility attribute on forward declaration of global variable */ | ||
960 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
961 | +/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
962 | + | ||
963 | +extern int __attribute__ ((visibility ("hidden"))) | ||
964 | +xyzzy; | ||
965 | + | ||
966 | +int xyzzy = 5; | ||
967 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C | ||
968 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C 1970-01-01 01:00:00.000000000 +0100 | ||
969 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C 2003-12-10 06:34:45.000000000 +0000 | ||
970 | @@ -0,0 +1,11 @@ | ||
971 | +/* Test visibility attribute on definition of a function that has | ||
972 | + already had a forward declaration. */ | ||
973 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
974 | +/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
975 | + | ||
976 | +void foo(); | ||
977 | + | ||
978 | +void | ||
979 | + __attribute__((visibility ("hidden"))) | ||
980 | +foo() | ||
981 | +{ } | ||
982 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C | ||
983 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C 1970-01-01 01:00:00.000000000 +0100 | ||
984 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C 2003-12-10 06:34:45.000000000 +0000 | ||
985 | @@ -0,0 +1,10 @@ | ||
986 | +/* Test visibility attribute on definition of global variable that has | ||
987 | + already had a forward declaration. */ | ||
988 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
989 | +/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
990 | + | ||
991 | +extern int xyzzy; | ||
992 | + | ||
993 | +int | ||
994 | +__attribute__((visibility ("hidden"))) | ||
995 | +xyzzy = 5; | ||
996 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C | ||
997 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C 1970-01-01 01:00:00.000000000 +0100 | ||
998 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C 2003-12-10 06:34:45.000000000 +0000 | ||
999 | @@ -0,0 +1,11 @@ | ||
1000 | +/* Test warning from conflicting visibility specifications. */ | ||
1001 | +/* { dg-do compile { target *86-*-linux* } } */ | ||
1002 | +/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
1003 | + | ||
1004 | +extern int | ||
1005 | +__attribute__((visibility ("hidden"))) | ||
1006 | +xyzzy; /* { dg-warning "previous declaration here" "" } */ | ||
1007 | + | ||
1008 | +int | ||
1009 | +__attribute__((visibility ("protected"))) | ||
1010 | +xyzzy = 5; /* { dg-warning "visibility attribute ignored" "" } */ | ||
1011 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-1.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-1.C | ||
1012 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-1.C 2003-12-10 06:34:44.000000000 +0000 | ||
1013 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-1.C 1970-01-01 01:00:00.000000000 +0100 | ||
1014 | @@ -1,8 +0,0 @@ | ||
1015 | -/* Test visibility attribute on function definition. */ | ||
1016 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1017 | -/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
1018 | - | ||
1019 | -void | ||
1020 | -__attribute__((visibility ("hidden"))) | ||
1021 | -foo() | ||
1022 | -{ } | ||
1023 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-2.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-2.C | ||
1024 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-2.C 2003-12-10 06:34:44.000000000 +0000 | ||
1025 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-2.C 1970-01-01 01:00:00.000000000 +0100 | ||
1026 | @@ -1,7 +0,0 @@ | ||
1027 | -/* Test that visibility attribute on declaration extends to definition. */ | ||
1028 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1029 | -/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
1030 | - | ||
1031 | -void __attribute__((visibility ("hidden"))) foo(); | ||
1032 | - | ||
1033 | -void foo() { } | ||
1034 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-3.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-3.C | ||
1035 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-3.C 2003-12-10 06:34:45.000000000 +0000 | ||
1036 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-3.C 1970-01-01 01:00:00.000000000 +0100 | ||
1037 | @@ -1,7 +0,0 @@ | ||
1038 | -/* Test visibility attribute on forward declaration of global variable */ | ||
1039 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1040 | -/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
1041 | - | ||
1042 | -int | ||
1043 | -__attribute__((visibility ("hidden"))) | ||
1044 | -xyzzy = 5; | ||
1045 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-4.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-4.C | ||
1046 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-4.C 2003-12-10 06:34:45.000000000 +0000 | ||
1047 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-4.C 1970-01-01 01:00:00.000000000 +0100 | ||
1048 | @@ -1,8 +0,0 @@ | ||
1049 | -/* Test visibility attribute on forward declaration of global variable */ | ||
1050 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1051 | -/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
1052 | - | ||
1053 | -extern int __attribute__ ((visibility ("hidden"))) | ||
1054 | -xyzzy; | ||
1055 | - | ||
1056 | -int xyzzy = 5; | ||
1057 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-5.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-5.C | ||
1058 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-5.C 2003-12-10 06:34:45.000000000 +0000 | ||
1059 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-5.C 1970-01-01 01:00:00.000000000 +0100 | ||
1060 | @@ -1,11 +0,0 @@ | ||
1061 | -/* Test visibility attribute on definition of a function that has | ||
1062 | - already had a forward declaration. */ | ||
1063 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1064 | -/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */ | ||
1065 | - | ||
1066 | -void foo(); | ||
1067 | - | ||
1068 | -void | ||
1069 | - __attribute__((visibility ("hidden"))) | ||
1070 | -foo() | ||
1071 | -{ } | ||
1072 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-6.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-6.C | ||
1073 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-6.C 2003-12-10 06:34:45.000000000 +0000 | ||
1074 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-6.C 1970-01-01 01:00:00.000000000 +0100 | ||
1075 | @@ -1,10 +0,0 @@ | ||
1076 | -/* Test visibility attribute on definition of global variable that has | ||
1077 | - already had a forward declaration. */ | ||
1078 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1079 | -/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
1080 | - | ||
1081 | -extern int xyzzy; | ||
1082 | - | ||
1083 | -int | ||
1084 | -__attribute__((visibility ("hidden"))) | ||
1085 | -xyzzy = 5; | ||
1086 | diff -Naur gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-7.C gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-7.C | ||
1087 | --- gcc-3.4.0orig/gcc/testsuite/g++.dg/ext/visibility-7.C 2003-12-10 06:34:45.000000000 +0000 | ||
1088 | +++ gcc-3.4.0/gcc/testsuite/g++.dg/ext/visibility-7.C 1970-01-01 01:00:00.000000000 +0100 | ||
1089 | @@ -1,11 +0,0 @@ | ||
1090 | -/* Test warning from conflicting visibility specifications. */ | ||
1091 | -/* { dg-do compile { target *86-*-linux* } } */ | ||
1092 | -/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */ | ||
1093 | - | ||
1094 | -extern int | ||
1095 | -__attribute__((visibility ("hidden"))) | ||
1096 | -xyzzy; /* { dg-warning "previous declaration here" "" } */ | ||
1097 | - | ||
1098 | -int | ||
1099 | -__attribute__((visibility ("protected"))) | ||
1100 | -xyzzy = 5; /* { dg-warning "visibility attribute ignored" "" } */ | ||