contrib/gcc34/gcc-3.4.6-visibility.patch

2033 lines
76 KiB
Diff
Raw Normal View History

2007-05-05 08:48:54 +02:00
diff -Nurp gcc-3.4.4.orig/gcc/c-common.c gcc-3.4.4/gcc/c-common.c
--- gcc-3.4.4.orig/gcc/c-common.c 2005-01-07 14:58:51.000000000 -0500
+++ gcc-3.4.4/gcc/c-common.c 2006-02-10 01:38:12.000000000 -0500
@@ -832,7 +832,7 @@ const struct attribute_spec c_common_att
handle_deprecated_attribute },
{ "vector_size", 1, 1, false, true, false,
handle_vector_size_attribute },
- { "visibility", 1, 1, true, false, false,
+ { "visibility", 1, 1, false, false, false,
handle_visibility_attribute },
{ "tls_model", 1, 1, true, false, false,
handle_tls_model_attribute },
@@ -4925,7 +4925,16 @@ handle_visibility_attribute (tree *node,
*no_add_attrs = true;
- if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl))
+ if (TYPE_P (*node))
+ {
+ if (TREE_CODE (*node) != RECORD_TYPE && TREE_CODE (*node) != UNION_TYPE)
+ {
+ warning ("`%s' attribute ignored on non-class types",
+ IDENTIFIER_POINTER (name));
+ return NULL_TREE;
+ }
+ }
+ else if (decl_function_context (decl) != 0 || ! TREE_PUBLIC (decl))
{
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
return NULL_TREE;
@@ -4936,6 +4945,14 @@ handle_visibility_attribute (tree *node,
error ("visibility arg not a string");
return NULL_TREE;
}
+
+ /* If this is a type, set the visibility on the type decl. */
+ if (TYPE_P (decl))
+ {
+ decl = TYPE_NAME (decl);
+ if (! decl)
+ return NULL_TREE;
+ }
if (strcmp (TREE_STRING_POINTER (id), "default") == 0)
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
@@ -4947,6 +4964,14 @@ handle_visibility_attribute (tree *node,
DECL_VISIBILITY (decl) = VISIBILITY_PROTECTED;
else
error ("visibility arg must be one of \"default\", \"hidden\", \"protected\" or \"internal\"");
+ DECL_VISIBILITY_SPECIFIED (decl) = 1;
+
+ /* For decls only, go ahead and attach the attribute to the node as well.
+ This is needed so we can determine whether we have VISIBILITY_DEFAULT
+ because the visibility was not specified, or because it was explicitly
+ overridden from the class visibility. */
+ if (DECL_P (*node))
+ *no_add_attrs = false;
return NULL_TREE;
}
diff -Nurp gcc-3.4.4.orig/gcc/c-decl.c gcc-3.4.4/gcc/c-decl.c
--- gcc-3.4.4.orig/gcc/c-decl.c 2005-05-01 06:43:46.000000000 -0400
+++ gcc-3.4.4/gcc/c-decl.c 2006-02-10 01:38:12.000000000 -0500
@@ -1164,9 +1164,8 @@ diagnose_mismatched_decls (tree newdecl,
}
/* warnings */
- /* All decls must agree on a non-default visibility. */
- if (DECL_VISIBILITY (newdecl) != VISIBILITY_DEFAULT
- && DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT
+ /* All decls must agree on a visibility. */
+ if (DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (olddecl)
&& DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
{
warning ("%Jredeclaration of '%D' with different visibility "
@@ -1366,9 +1365,12 @@ merge_decls (tree newdecl, tree olddecl,
Currently, it can only be defined in the prototype. */
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
- /* If either declaration has a nondefault visibility, use it. */
- if (DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT)
- DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
+ /* Use visibility of whichever declaration had it specified */
+ if (DECL_VISIBILITY_SPECIFIED (olddecl))
+ {
+ DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
+ DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
+ }
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
diff -Nurp gcc-3.4.4.orig/gcc/c-opts.c gcc-3.4.4/gcc/c-opts.c
--- gcc-3.4.4.orig/gcc/c-opts.c 2005-03-08 20:00:56.000000000 -0500
+++ gcc-3.4.4/gcc/c-opts.c 2006-02-10 01:38:12.000000000 -0500
@@ -920,6 +920,10 @@ c_common_handle_option (size_t scode, co
case OPT_fuse_cxa_atexit:
flag_use_cxa_atexit = value;
break;
+
+ case OPT_fvisibility_inlines_hidden:
+ visibility_options.inlines_hidden = value;
+ break;
case OPT_fweak:
flag_weak = value;
diff -Nurp gcc-3.4.4.orig/gcc/c-pragma.c gcc-3.4.4/gcc/c-pragma.c
--- gcc-3.4.4.orig/gcc/c-pragma.c 2004-05-07 03:07:30.000000000 -0400
+++ gcc-3.4.4/gcc/c-pragma.c 2006-02-10 01:38:12.000000000 -0500
@@ -481,6 +481,86 @@ maybe_apply_renaming_pragma (tree decl,
return asmname;
}
+
+#ifdef HANDLE_PRAGMA_VISIBILITY
+static void handle_pragma_visibility (cpp_reader *);
+
+/* 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;
+ tree x;
+ enum cpp_ttype token;
+ enum { bad, push, pop } action = bad;
+
+ token = c_lex (&x);
+ if (token == CPP_NAME)
+ {
+ const char *op = IDENTIFIER_POINTER (x);
+ if (!strcmp (op, "push"))
+ action = push;
+ else if (!strcmp (op, "pop"))
+ action = pop;
+ }
+ if (bad == action)
+ GCC_BAD ("#pragma GCC visibility must be followed by push or pop");
+ else
+ {
+ if (pop == action)
+ {
+ if (!visidx)
+ {
+ GCC_BAD ("No matching push for '#pragma GCC visibility pop'");
+ }
+ else
+ {
+ default_visibility = visstack[--visidx];
+ visibility_options.inpragma = (visidx>0);
+ }
+ }
+ else
+ {
+ if (c_lex (&x) != CPP_OPEN_PAREN)
+ GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored");
+ token = c_lex (&x);
+ if (token != CPP_NAME)
+ {
+ 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;
+ if (!strcmp (str, "default"))
+ default_visibility = VISIBILITY_DEFAULT;
+ else if (!strcmp (str, "internal"))
+ default_visibility = VISIBILITY_INTERNAL;
+ else if (!strcmp (str, "hidden"))
+ default_visibility = VISIBILITY_HIDDEN;
+ else if (!strcmp (str, "protected"))
+ default_visibility = VISIBILITY_PROTECTED;
+ else
+ {
+ GCC_BAD ("#pragma GCC visibility push() must specify default, internal, hidden or protected");
+ }
+ visibility_options.inpragma = 1;
+ }
+ if (c_lex (&x) != CPP_CLOSE_PAREN)
+ GCC_BAD ("missing '(' after '#pragma GCC visibility push' - ignored");
+ }
+ }
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of '#pragma GCC visibility'");
+}
+
+#endif
+
/* Front-end wrapper for pragma registration to avoid dragging
cpplib.h in almost everywhere. */
void
@@ -506,6 +586,9 @@ init_pragma (void)
#ifdef HANDLE_PRAGMA_EXTERN_PREFIX
c_register_pragma (0, "extern_prefix", handle_pragma_extern_prefix);
#endif
+#ifdef HANDLE_PRAGMA_VISIBILITY
+ c_register_pragma ("GCC", "visibility", handle_pragma_visibility);
+#endif
#ifdef REGISTER_TARGET_PRAGMAS
REGISTER_TARGET_PRAGMAS ();
diff -Nurp gcc-3.4.4.orig/gcc/c-pragma.h gcc-3.4.4/gcc/c-pragma.h
--- gcc-3.4.4.orig/gcc/c-pragma.h 2004-01-31 01:18:05.000000000 -0500
+++ gcc-3.4.4/gcc/c-pragma.h 2006-02-10 01:38:12.000000000 -0500
@@ -44,6 +44,11 @@ extern struct cpp_reader* parse_in;
#define HANDLE_PRAGMA_PACK 1
#endif /* HANDLE_PRAGMA_PACK_PUSH_POP */
+/* It's safe to always leave visibility pragma enabled as if
+ visibility is not supported on the host OS platform the
+ statements are ignored. */
+#define HANDLE_PRAGMA_VISIBILITY 1
+
extern void init_pragma (void);
/* Front-end wrapper for pragma registration to avoid dragging
diff -Nurp gcc-3.4.4.orig/gcc/c.opt gcc-3.4.4/gcc/c.opt
--- gcc-3.4.4.orig/gcc/c.opt 2005-03-19 15:30:38.000000000 -0500
+++ gcc-3.4.4/gcc/c.opt 2006-02-10 01:38:12.000000000 -0500
@@ -656,6 +656,10 @@ fuse-cxa-atexit
C++ ObjC++
Use __cxa_atexit to register destructors
+fvisibility-inlines-hidden
+C++
+Marks all inlined methods as having hidden visibility
+
fvtable-gc
C++ ObjC++
Discard unused virtual functions
diff -Nurp gcc-3.4.4.orig/gcc/common.opt gcc-3.4.4/gcc/common.opt
--- gcc-3.4.4.orig/gcc/common.opt 2004-10-27 23:43:09.000000000 -0400
+++ gcc-3.4.4/gcc/common.opt 2006-02-10 01:38:12.000000000 -0500
@@ -718,6 +718,11 @@ fverbose-asm
Common
Add extra commentary to assembler output
+fvisibility=
+Common Joined RejectNegative
+-fvisibility=[default|internal|hidden|protected] Set the default symbol visibility
+
+
fvpt
Common
Use expression value profiles in optimizations
diff -Nurp gcc-3.4.4.orig/gcc/cp/class.c gcc-3.4.4/gcc/cp/class.c
--- gcc-3.4.4.orig/gcc/cp/class.c 2005-05-09 07:47:53.000000000 -0400
+++ gcc-3.4.4/gcc/cp/class.c 2006-02-10 01:38:15.000000000 -0500
@@ -6799,14 +6799,9 @@ initialize_vtable (tree binfo, tree init
static void
initialize_array (tree decl, tree inits)
{
- tree context;
-
- context = DECL_CONTEXT (decl);
- DECL_CONTEXT (decl) = NULL_TREE;
DECL_INITIAL (decl) = build_constructor (NULL_TREE, inits);
TREE_HAS_CONSTRUCTOR (DECL_INITIAL (decl)) = 1;
cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0);
- DECL_CONTEXT (decl) = context;
}
/* Build the VTT (virtual table table) for T.
diff -Nurp gcc-3.4.4.orig/gcc/cp/cp-tree.h gcc-3.4.4/gcc/cp/cp-tree.h
--- gcc-3.4.4.orig/gcc/cp/cp-tree.h 2005-05-09 07:47:57.000000000 -0400
+++ gcc-3.4.4/gcc/cp/cp-tree.h 2006-02-10 01:38:15.000000000 -0500
@@ -75,6 +75,7 @@ struct diagnostic_context;
or FIELD_DECL).
NEED_TEMPORARY_P (in REF_BIND, BASE_CONV)
IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
+ DECL_TINFO_P (in VAR_DECL)
5: C_IS_RESERVED_WORD (in IDENTIFIER_NODE)
DECL_VTABLE_OR_VTT_P (in VAR_DECL)
6: For future expansion
@@ -1008,7 +1009,12 @@ enum languages { lang_c, lang_cplusplus,
#define PUBLICLY_UNIQUELY_DERIVED_P(PARENT, TYPE) \
(lookup_base ((TYPE), (PARENT), ba_not_special | ba_quiet, NULL) \
!= NULL_TREE)
-
+
+/* Gives the visibility specification for a class type. */
+#define CLASSTYPE_VISIBILITY(TYPE) DECL_VISIBILITY (TYPE_NAME (TYPE))
+#define CLASSTYPE_VISIBILITY_SPECIFIED(TYPE) DECL_VISIBILITY_SPECIFIED (TYPE_NAME (TYPE))
+
+
/* This is a few header flags for 'struct lang_type'. Actually,
all but the first are used only for lang_type_class; they
are put in this structure to save space. */
@@ -2064,6 +2070,10 @@ struct lang_decl GTY(())
(DECL_CONTEXT (NODE) \
&& TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
+/* 1 iff VAR_DECL node NODE is a type-info decl. This flag is set for
+ both the primary typeinfo object and the associated NTBS name. */
+#define DECL_TINFO_P(NODE) TREE_LANG_FLAG_4 (VAR_DECL_CHECK (NODE))
+
/* 1 iff VAR_DECL node NODE is virtual table or VTT. */
#define DECL_VTABLE_OR_VTT_P(NODE) TREE_LANG_FLAG_5 (VAR_DECL_CHECK (NODE))
@@ -3669,7 +3679,7 @@ extern int init_type_desc (void);
extern tree check_tag_decl (tree);
extern tree shadow_tag (tree);
extern tree groktypename (tree);
-extern tree start_decl (tree, tree, int, tree, tree);
+extern tree start_decl (tree, tree, int, tree, tree, bool *);
extern void start_decl_1 (tree);
extern void cp_finish_decl (tree, tree, tree, int);
extern void finish_decl (tree, tree, tree);
@@ -3754,6 +3764,7 @@ extern tree finish_table (tree, tree, tr
extern tree coerce_new_type (tree);
extern tree coerce_delete_type (tree);
extern void comdat_linkage (tree);
+extern void determine_visibility (tree);
extern void import_export_vtable (tree, tree, int);
extern void import_export_decl (tree);
extern void import_export_tinfo (tree, tree, bool);
diff -Nurp gcc-3.4.4.orig/gcc/cp/decl.c gcc-3.4.4/gcc/cp/decl.c
--- gcc-3.4.4.orig/gcc/cp/decl.c 2005-03-19 09:00:45.000000000 -0500
+++ gcc-3.4.4/gcc/cp/decl.c 2006-02-10 01:38:15.000000000 -0500
@@ -1889,17 +1889,20 @@ duplicate_decls (tree newdecl, tree oldd
DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
- /* If either declaration has a nondefault visibility, use it. */
- if (DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT)
+ /* Warn about conflicting visibility specifications. */
+ if (DECL_VISIBILITY_SPECIFIED (olddecl)
+ && DECL_VISIBILITY_SPECIFIED (newdecl)
+ && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
+ {
+ warning ("%J'%D': visibility attribute ignored because it",
+ newdecl, newdecl);
+ warning ("%Jconflicts with previous declaration here", olddecl);
+ }
+ /* Choose the declaration which specified visibility. */
+ if (DECL_VISIBILITY_SPECIFIED (olddecl))
{
- if (DECL_VISIBILITY (newdecl) != VISIBILITY_DEFAULT
- && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
- {
- warning ("%J'%D': visibility attribute ignored because it",
- newdecl, newdecl);
- warning ("%Jconflicts with previous declaration here", olddecl);
- }
DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
+ DECL_VISIBILITY_SPECIFIED (newdecl) = 1;
}
if (TREE_CODE (newdecl) == FUNCTION_DECL)
@@ -3321,6 +3324,10 @@ build_library_fn_1 (tree name, enum tree
TREE_NOTHROW (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, operator_code);
SET_DECL_LANGUAGE (fn, lang_c);
+ /* Runtime library routines are, by definition, available in an
+ external shared object. */
+ DECL_VISIBILITY (fn) = VISIBILITY_DEFAULT;
+ DECL_VISIBILITY_SPECIFIED (fn) = 1;
return fn;
}
@@ -3684,7 +3691,8 @@ start_decl (tree declarator,
tree declspecs,
int initialized,
tree attributes,
- tree prefix_attributes)
+ tree prefix_attributes,
+ bool *pop_scope_p)
{
tree decl;
tree type, tem;
@@ -3720,14 +3728,11 @@ start_decl (tree declarator,
context = DECL_CONTEXT (decl);
- if (initialized && context && TREE_CODE (context) == NAMESPACE_DECL
- && context != current_namespace && TREE_CODE (decl) == VAR_DECL)
- {
- /* When parsing the initializer, lookup should use the object's
- namespace. */
- push_decl_namespace (context);
- }
-
+ if (context)
+ *pop_scope_p = push_scope (context);
+ else
+ *pop_scope_p = false;
+
/* We are only interested in class contexts, later. */
if (context && TREE_CODE (context) == NAMESPACE_DECL)
context = NULL_TREE;
@@ -3783,8 +3788,6 @@ start_decl (tree declarator,
if (context && COMPLETE_TYPE_P (complete_type (context)))
{
- push_nested_class (context);
-
if (TREE_CODE (decl) == VAR_DECL)
{
tree field = lookup_field (context, DECL_NAME (decl), 0, false);
@@ -4820,20 +4823,10 @@ cp_finish_decl (tree decl, tree init, tr
&& (DECL_INITIAL (decl) || init))
DECL_INITIALIZED_IN_CLASS_P (decl) = 1;
- if (TREE_CODE (decl) == VAR_DECL
- && DECL_CONTEXT (decl)
- && TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL
- && DECL_CONTEXT (decl) != current_namespace
- && init)
- {
- /* Leave the namespace of the object. */
- pop_decl_namespace ();
- }
-
type = TREE_TYPE (decl);
if (type == error_mark_node)
- goto finish_end0;
+ goto finish_end;
if (TYPE_HAS_MUTABLE_P (type))
TREE_READONLY (decl) = 0;
@@ -4850,7 +4843,7 @@ cp_finish_decl (tree decl, tree init, tr
&& !DECL_PRETTY_FUNCTION_P (decl)
&& !dependent_type_p (TREE_TYPE (decl)))
maybe_deduce_size_from_array_init (decl, init);
- goto finish_end0;
+ goto finish_end;
}
/* Parameters are handled by store_parm_decls, not cp_finish_decl. */
@@ -4943,6 +4936,9 @@ cp_finish_decl (tree decl, tree init, tr
the class specifier. */
if (!DECL_EXTERNAL (decl))
var_definition_p = true;
+ /* The variable is being defined, so determine its
+ visibility. */
+ determine_visibility (decl);
}
/* If the variable has an array type, lay out the type, even if
there is no initializer. It is valid to index through the
@@ -5028,26 +5024,6 @@ cp_finish_decl (tree decl, tree init, tr
if (var_definition_p && TREE_STATIC (decl))
expand_static_init (decl, init);
}
- finish_end0:
-
- /* Undo call to `pushclass' that was done in `start_decl'
- due to initialization of qualified member variable.
- I.e., Foo::x = 10; */
- {
- tree context = CP_DECL_CONTEXT (decl);
- if (context
- && TYPE_P (context)
- && (TREE_CODE (decl) == VAR_DECL
- /* We also have a pushclass done that we need to undo here
- if we're at top level and declare a method. */
- || TREE_CODE (decl) == FUNCTION_DECL)
- /* If size hasn't been set, we're still defining it,
- and therefore inside the class body; don't pop
- the binding level.. */
- && COMPLETE_TYPE_P (context)
- && context == current_class_type)
- pop_nested_class ();
- }
}
/* If a CLEANUP_STMT was created to destroy a temporary bound to a
@@ -10244,6 +10220,9 @@ start_function (tree declspecs, tree dec
&& lookup_attribute ("noinline", attrs))
warning ("%Jinline function '%D' given attribute noinline", decl1, decl1);
+ /* Determine the ELF visibility attribute for the function. */
+ determine_visibility (decl1);
+
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl1))
/* This is a constructor, we must ensure that any default args
introduced by this definition are propagated to the clones
diff -Nurp gcc-3.4.4.orig/gcc/cp/decl2.c gcc-3.4.4/gcc/cp/decl2.c
--- gcc-3.4.4.orig/gcc/cp/decl2.c 2004-10-11 10:42:36.000000000 -0400
+++ gcc-3.4.4/gcc/cp/decl2.c 2006-02-10 01:38:24.000000000 -0500
@@ -1658,6 +1658,63 @@ maybe_emit_vtables (tree ctype)
return true;
}
+/* Determine the ELF symbol visibility for DECL. */
+
+void
+determine_visibility (tree decl)
+{
+ tree class_type;
+
+ /* Cloned constructors and destructors get the same visibility as
+ the underlying function. That should be set up in
+ maybe_clone_body. */
+ if (DECL_CLONED_FUNCTION_P (decl))
+ return;
+
+ if (DECL_CLASS_SCOPE_P (decl))
+ class_type = DECL_CONTEXT (decl);
+ else if (TREE_CODE (decl) == VAR_DECL
+ && DECL_TINFO_P (decl)
+ && CLASS_TYPE_P (TREE_TYPE (DECL_NAME (decl))))
+ class_type = TREE_TYPE (DECL_NAME (decl));
+ else
+ {
+ /* Virtual tables have DECL_CONTEXT set to their associated class,
+ so they are automatically handled above. */
+ my_friendly_assert (!(TREE_CODE (decl) == VAR_DECL
+ && DECL_VTABLE_OR_VTT_P (decl)), 20040803);
+ /* Entities not associated with any class just get the
+ visibility specified by their attributes. */
+ return;
+ }
+
+ /* By default, static data members and function members receive
+ the visibility of their containing class. */
+ if (class_type
+ && (TREE_CODE (decl) == VAR_DECL
+ || TREE_CODE (decl) == FUNCTION_DECL)
+ && !lookup_attribute ("visibility", DECL_ATTRIBUTES (decl)))
+ {
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_DECLARED_INLINE_P (decl)
+ && visibility_options.inlines_hidden)
+ {
+ /* Don't change it if it has been set explicitly by user. */
+ if (!DECL_VISIBILITY_SPECIFIED (decl))
+ {
+ DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
+ DECL_VISIBILITY_SPECIFIED (decl) = 1;
+ }
+ }
+ else
+ {
+ DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type);
+ DECL_VISIBILITY_SPECIFIED (decl)
+ = CLASSTYPE_VISIBILITY_SPECIFIED (class_type);
+ }
+ }
+}
+
/* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
inline function or template instantiation at end-of-file. */
diff -Nurp gcc-3.4.4.orig/gcc/cp/method.c gcc-3.4.4/gcc/cp/method.c
--- gcc-3.4.4.orig/gcc/cp/method.c 2005-05-09 07:48:01.000000000 -0400
+++ gcc-3.4.4/gcc/cp/method.c 2006-02-10 01:38:15.000000000 -0500
@@ -398,6 +398,8 @@ use_thunk (tree thunk_fndecl, bool emit_
rewrite. */
TREE_PUBLIC (thunk_fndecl) = TREE_PUBLIC (function);
DECL_VISIBILITY (thunk_fndecl) = DECL_VISIBILITY (function);
+ DECL_VISIBILITY_SPECIFIED (thunk_fndecl)
+ = DECL_VISIBILITY_SPECIFIED (function);
if (flag_syntax_only)
{
diff -Nurp gcc-3.4.4.orig/gcc/cp/optimize.c gcc-3.4.4/gcc/cp/optimize.c
--- gcc-3.4.4.orig/gcc/cp/optimize.c 2004-02-07 20:52:50.000000000 -0500
+++ gcc-3.4.4/gcc/cp/optimize.c 2006-02-10 01:38:12.000000000 -0500
@@ -155,6 +155,7 @@ maybe_clone_body (tree fn)
DECL_NOT_REALLY_EXTERN (clone) = DECL_NOT_REALLY_EXTERN (fn);
TREE_PUBLIC (clone) = TREE_PUBLIC (fn);
DECL_VISIBILITY (clone) = DECL_VISIBILITY (fn);
+ DECL_VISIBILITY_SPECIFIED (clone) = DECL_VISIBILITY_SPECIFIED (fn);
/* Adjust the parameter names and locations. */
parm = DECL_ARGUMENTS (fn);
diff -Nurp gcc-3.4.4.orig/gcc/cp/parser.c gcc-3.4.4/gcc/cp/parser.c
--- gcc-3.4.4.orig/gcc/cp/parser.c 2005-04-04 19:43:47.000000000 -0400
+++ gcc-3.4.4/gcc/cp/parser.c 2006-02-10 01:38:15.000000000 -0500
@@ -5881,10 +5881,13 @@ cp_parser_condition (cp_parser* parser)
for sure. */
if (cp_parser_parse_definitely (parser))
{
+ bool pop_p;
+
/* Create the declaration. */
decl = start_decl (declarator, type_specifiers,
/*initialized_p=*/true,
- attributes, /*prefix_attributes=*/NULL_TREE);
+ attributes, /*prefix_attributes=*/NULL_TREE,
+ &pop_p);
/* Parse the assignment-expression. */
initializer = cp_parser_assignment_expression (parser);
@@ -5893,7 +5896,9 @@ cp_parser_condition (cp_parser* parser)
initializer,
asm_specification,
LOOKUP_ONLYCONVERTING);
-
+ if (pop_p)
+ pop_scope (DECL_CONTEXT (decl));
+
return convert_from_reference (decl);
}
}
@@ -10109,12 +10114,12 @@ cp_parser_init_declarator (cp_parser* pa
have_extern_spec = false;
}
decl = start_decl (declarator, decl_specifiers,
- is_initialized, attributes, prefix_attributes);
+ is_initialized, attributes, prefix_attributes,
+ &pop_p);
}
-
- /* Enter the SCOPE. That way unqualified names appearing in the
- initializer will be looked up in SCOPE. */
- if (scope)
+ else if (scope)
+ /* Enter the SCOPE. That way unqualified names appearing in the
+ initializer will be looked up in SCOPE. */
pop_p = push_scope (scope);
/* Perform deferred access control checks, now that we know in which
@@ -10161,17 +10166,13 @@ cp_parser_init_declarator (cp_parser* pa
if (cp_parser_attributes_opt (parser))
warning ("attributes after parenthesized initializer ignored");
- /* Leave the SCOPE, now that we have processed the initializer. It
- is important to do this before calling cp_finish_decl because it
- makes decisions about whether to create DECL_STMTs or not based
- on the current scope. */
- if (pop_p)
- pop_scope (scope);
-
/* For an in-class declaration, use `grokfield' to create the
declaration. */
if (member_p)
{
+ if (pop_p)
+ pop_scope (scope);
+
decl = grokfield (declarator, decl_specifiers,
initializer, /*asmspec=*/NULL_TREE,
/*attributes=*/NULL_TREE);
@@ -10182,15 +10183,19 @@ cp_parser_init_declarator (cp_parser* pa
/* Finish processing the declaration. But, skip friend
declarations. */
if (!friend_p && decl)
- cp_finish_decl (decl,
- initializer,
- asm_specification,
- /* If the initializer is in parentheses, then this is
- a direct-initialization, which means that an
- `explicit' constructor is OK. Otherwise, an
- `explicit' constructor cannot be used. */
- ((is_parenthesized_init || !is_initialized)
- ? 0 : LOOKUP_ONLYCONVERTING));
+ {
+ cp_finish_decl (decl,
+ initializer,
+ asm_specification,
+ /* If the initializer is in parentheses, then this is
+ a direct-initialization, which means that an
+ `explicit' constructor is OK. Otherwise, an
+ `explicit' constructor cannot be used. */
+ ((is_parenthesized_init || !is_initialized)
+ ? 0 : LOOKUP_ONLYCONVERTING));
+ if (pop_p)
+ pop_scope (DECL_CONTEXT (decl));
+ }
/* Remember whether or not variables were initialized by
constant-expressions. */
diff -Nurp gcc-3.4.4.orig/gcc/cp/pt.c gcc-3.4.4/gcc/cp/pt.c
--- gcc-3.4.4.orig/gcc/cp/pt.c 2005-03-06 11:59:08.000000000 -0500
+++ gcc-3.4.4/gcc/cp/pt.c 2006-02-10 01:38:15.000000000 -0500
@@ -11265,20 +11265,13 @@ instantiate_decl (tree d, int defer_ok)
}
else
{
- /* This is done in analogous to `start_decl'. It is
- required for correct access checking. */
+ /* Enter the scope of D so that access-checking works correctly. */
push_nested_class (DECL_CONTEXT (d));
cp_finish_decl (d,
(!DECL_INITIALIZED_IN_CLASS_P (d)
? DECL_INITIAL (d) : NULL_TREE),
NULL_TREE, 0);
- /* Normally, pop_nested_class is called by cp_finish_decl
- above. But when instantiate_decl is triggered during
- instantiate_class_template processing, its DECL_CONTEXT
- is still not completed yet, and pop_nested_class isn't
- called. */
- if (!COMPLETE_TYPE_P (DECL_CONTEXT (d)))
- pop_nested_class ();
+ pop_nested_class ();
}
/* We're not deferring instantiation any more. */
TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (d)) = 0;
diff -Nurp gcc-3.4.4.orig/gcc/cp/rtti.c gcc-3.4.4/gcc/cp/rtti.c
--- gcc-3.4.4.orig/gcc/cp/rtti.c 2004-07-12 18:26:39.000000000 -0400
+++ gcc-3.4.4/gcc/cp/rtti.c 2006-02-10 01:38:15.000000000 -0500
@@ -354,17 +354,16 @@ get_tinfo_decl (tree type)
TREE_READONLY (d) = 1;
TREE_STATIC (d) = 1;
DECL_EXTERNAL (d) = 1;
+ DECL_TINFO_P (d) = 1;
DECL_COMDAT (d) = 1;
TREE_PUBLIC (d) = 1;
SET_DECL_ASSEMBLER_NAME (d, name);
-
- pushdecl_top_level_and_finish (d, NULL_TREE);
-
+ /* Remember the type it is for. */
+ TREE_TYPE (name) = type;
if (CLASS_TYPE_P (type))
CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d;
- /* Remember the type it is for. */
- TREE_TYPE (name) = type;
+ pushdecl_top_level_and_finish (d, NULL_TREE);
/* Add decl to the global array of tinfo decls. */
my_friendly_assert (unemitted_tinfo_decls != 0, 20030312);
@@ -751,19 +750,20 @@ tinfo_base_init (tree desc, tree target)
NULL_TREE);
tree name_string = tinfo_name (target);
+ /* Determine the name of the variable -- and remember with which
+ type it is associated. */
name_name = mangle_typeinfo_string_for_type (target);
+ TREE_TYPE (name_name) = target;
+
name_decl = build_lang_decl (VAR_DECL, name_name, name_type);
-
+ SET_DECL_ASSEMBLER_NAME (name_decl, name_name);
DECL_ARTIFICIAL (name_decl) = 1;
TREE_READONLY (name_decl) = 1;
TREE_STATIC (name_decl) = 1;
DECL_EXTERNAL (name_decl) = 0;
+ DECL_TINFO_P (name_decl) = 1;
TREE_PUBLIC (name_decl) = 1;
import_export_tinfo (name_decl, target, typeinfo_in_lib_p (target));
- /* External name of the string containing the type's name has a
- special name. */
- SET_DECL_ASSEMBLER_NAME (name_decl,
- mangle_typeinfo_string_for_type (target));
DECL_INITIAL (name_decl) = name_string;
mark_used (name_decl);
pushdecl_top_level_and_finish (name_decl, name_string);
diff -Nurp gcc-3.4.4.orig/gcc/doc/invoke.texi gcc-3.4.4/gcc/doc/invoke.texi
--- gcc-3.4.4.orig/gcc/doc/invoke.texi 2005-04-22 02:49:59.000000000 -0400
+++ gcc-3.4.4/gcc/doc/invoke.texi 2006-02-10 01:38:12.000000000 -0500
@@ -183,7 +183,8 @@ in the following sections.
-fno-optional-diags -fpermissive @gol
-frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
-fuse-cxa-atexit -fno-weak -nostdinc++ @gol
--fno-default-inline -Wabi -Wctor-dtor-privacy @gol
+-fno-default-inline -fvisibility-inlines-hidden @gol
+-Wabi -Wctor-dtor-privacy @gol
-Wnon-virtual-dtor -Wreorder @gol
-Weffc++ -Wno-deprecated @gol
-Wno-non-template-friend -Wold-style-cast @gol
@@ -678,7 +679,8 @@ in the following sections.
-fargument-alias -fargument-noalias @gol
-fargument-noalias-global -fleading-underscore @gol
-ftls-model=@var{model} @gol
--ftrapv -fwrapv -fbounds-check}
+-ftrapv -fwrapv -fbounds-check @gol
+-fvisibility}
@end table
@menu
@@ -1437,6 +1439,20 @@ This option is required for fully standa
destructors, but will only work if your C library supports
@code{__cxa_atexit}.
+@item -fvisibility-inlines-hidden
+@opindex fvisibility-inlines-hidden
+Causes all inlined methods to be marked with
+@code{__attribute__ ((visibility ("hidden")))} so that they do not
+appear in the export table of a DSO and do not require a PLT indirection
+when used within the DSO. Enabling this option can have a dramatic effect
+on load and link times of a DSO as it massively reduces the size of the
+dynamic export table when the library makes heavy use of templates. While
+it can cause bloating through duplication of code within each DSO where
+it is used, often the wastage is less than the considerable space occupied
+by a long symbol name in the export table which is typical when using
+templates and namespaces. For even more savings, combine with the
+@code{-fvisibility=hidden} switch.
+
@item -fno-weak
@opindex fno-weak
Do not use weak symbol support, even if it is provided by the linker.
@@ -11270,6 +11286,54 @@ The @var{model} argument should be one o
The default without @option{-fpic} is @code{initial-exec}; with
@option{-fpic} the default is @code{global-dynamic}.
+
+@item -fvisibility=@var{default|internal|hidden|protected}
+@opindex fvisibility
+Set the default ELF image symbol visibility to the specified option - all
+symbols will be marked with this unless overrided within the code.
+Using this feature can very substantially improve linking and
+load times of shared object libraries, produce more optimised
+code, provide near-perfect API export and prevent symbol clashes.
+It is @strong{strongly} recommended that you use this in any shared objects
+you distribute.
+
+Despite the nomenclature, @code{default} always means public ie;
+available to be linked against from outside the shared object.
+@code{protected} and @code{internal} are pretty useless in real-world
+usage so the only other commonly used option will be @code{hidden}.
+The default if -fvisibility isn't specified is @code{default} ie; make every
+symbol public - this causes the same behaviour as previous versions of
+GCC.
+
+A good explanation of the benefits offered by ensuring ELF
+symbols have the correct visibility is given by ``How To Write
+Shared Libraries'' by Ulrich Drepper (which can be found at
+@w{@uref{http://people.redhat.com/~drepper/}}) - however a superior
+solution made possible by this option to marking things hidden when
+the default is public is to make the default hidden and mark things
+public. This is the norm with DLL's on Windows and with @option{-fvisibility=hidden}
+and @code{__attribute__ ((visibility("default")))} instead of
+@code{__declspec(dllexport)} you get almost identical semantics with
+identical syntax. This is a great boon to those working with
+cross-platform projects.
+
+For those adding visibility support to existing code, you may find
+@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
+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
+as hidden as so to avoid PLT indirection overheads - making this
+abundantly clear also aids readability and self-documentation of the code.
+Note that due to ISO C++ specification requirements, operator new and
+operator delete must always be of default visibility.
+
+An overview of these techniques, their benefits and how to use them
+is at @w{@uref{http://www.nedprod.com/programs/gccvisibility.html}}.
+
@end table
@c man end
diff -Nurp gcc-3.4.4.orig/gcc/flags.h gcc-3.4.4/gcc/flags.h
--- gcc-3.4.4.orig/gcc/flags.h 2004-02-17 19:09:04.000000000 -0500
+++ gcc-3.4.4/gcc/flags.h 2006-02-10 01:38:12.000000000 -0500
@@ -60,6 +60,30 @@ extern bool use_gnu_debug_info_extension
/* Nonzero means emit debugging information only for symbols which are used. */
extern int flag_debug_only_used_symbols;
+/* Enumerate visibility settings. */
+#ifndef SYMBOL_VISIBILITY_DEFINED
+#define SYMBOL_VISIBILITY_DEFINED
+enum symbol_visibility
+{
+ VISIBILITY_DEFAULT,
+ VISIBILITY_INTERNAL,
+ VISIBILITY_HIDDEN,
+ VISIBILITY_PROTECTED
+};
+#endif
+
+/* The default visibility for all symbols (unless overridden). */
+extern enum symbol_visibility default_visibility;
+
+struct visibility_flags
+{
+ unsigned inpragma : 1; /* True when in #pragma GCC visibility. */
+ unsigned inlines_hidden : 1; /* True when -finlineshidden in effect. */
+};
+
+/* Global visibility options. */
+extern struct visibility_flags visibility_options;
+
/* Nonzero means do optimizations. -opt. */
extern int optimize;
diff -Nurp gcc-3.4.4.orig/gcc/opts.c gcc-3.4.4/gcc/opts.c
--- gcc-3.4.4.orig/gcc/opts.c 2004-02-17 19:09:04.000000000 -0500
+++ gcc-3.4.4/gcc/opts.c 2006-02-10 01:38:12.000000000 -0500
@@ -142,6 +142,12 @@ enum debug_info_level debug_info_level =
write_symbols is set to DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */
bool use_gnu_debug_info_extensions;
+/* The default visibility for all symbols (unless overridden) */
+enum symbol_visibility default_visibility = VISIBILITY_DEFAULT;
+
+/* Global visibility options. */
+struct visibility_flags visibility_options;
+
/* Columns of --help display. */
static unsigned int columns = 80;
@@ -1214,6 +1220,21 @@ common_handle_option (size_t scode, cons
flag_profile_values = value;
break;
+ case OPT_fvisibility_:
+ {
+ if (!strcmp(arg, "default"))
+ default_visibility = VISIBILITY_DEFAULT;
+ else if (!strcmp(arg, "internal"))
+ default_visibility = VISIBILITY_INTERNAL;
+ else if (!strcmp(arg, "hidden"))
+ default_visibility = VISIBILITY_HIDDEN;
+ else if (!strcmp(arg, "protected"))
+ default_visibility = VISIBILITY_PROTECTED;
+ else
+ error ("unrecognised visibility value \"%s\"", arg);
+ }
+ break;
+
case OPT_fvpt:
flag_value_profile_transformations_set = value;
flag_value_profile_transformations = value;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/assign1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/assign1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/assign1.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/assign1.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "_ZN1DaSERKS_" } } */
+
+struct B {
+ B& operator=(const B&);
+};
+
+struct D : public B {
+ // The implicit assignment operator should be hidden.
+} __attribute__((visibility("hidden")));
+
+D d1, d2;
+
+void f() {
+ d1 = d2;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-inlines-hidden.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,18 @@
+/* Test that -fvisibility-inlines-hidden affects class members. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fvisibility-inlines-hidden" } */
+/* { dg-final { scan-hidden "_ZN3Foo6methodEv" } } */
+
+class Foo
+{
+public:
+ void method() { }
+};
+
+int main(void)
+{
+ Foo f;
+ f.method();
+ return 0;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override1.C 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,12 @@
+/* Test that -fvisibility does not override class member specific settings. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fvisibility=hidden" } */
+/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */
+
+class __attribute__ ((visibility ("internal"))) Foo
+{
+ void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility-override2.C 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,12 @@
+/* Test that -fvisibility does not override class member specific settings. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fvisibility=hidden" } */
+/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */
+
+class Foo
+{
+ __attribute__ ((visibility ("internal"))) void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/fvisibility.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,12 @@
+/* Test that -fvisibility affects class members. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fvisibility=hidden" } */
+/* { dg-final { scan-hidden "_ZN3Foo6methodEv" } } */
+
+class Foo
+{
+ void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/memfuncts.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,11 @@
+/* Test that setting visibility for class member functions works. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "_ZN3Foo6methodEv" } } */
+
+class __attribute__ ((visibility ("hidden"))) Foo
+{
+ void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/new1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/new1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/new1.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/new1.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,13 @@
+// { dg-require-visibility "" }
+// { dg-options "-fvisibility=hidden" }
+// { dg-final { scan-not-hidden "_Znwj" } }
+
+void f() {
+ new int;
+}
+
+void *g();
+
+void *operator new(__SIZE_TYPE__) {
+ return g();
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/noPLT.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/noPLT.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/noPLT.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/noPLT.C 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,20 @@
+/* Test that -fvisibility=hidden prevents PLT. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fPIC -fvisibility=hidden" } */
+/* { dg-final { scan-assembler-not "methodEv@PLT" } } */
+
+class Foo
+{
+public:
+ void method();
+};
+
+void Foo::method() { }
+
+int main(void)
+{
+ Foo f;
+ f.method();
+ return 0;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma-override1.C 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,13 @@
+/* Test that #pragma GCC visibility does not override class member specific settings. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */
+
+#pragma GCC visibility push(hidden)
+class __attribute__ ((visibility ("internal"))) Foo
+{
+ void method();
+};
+#pragma GCC visibility pop
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma-override2.C 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,13 @@
+/* Test that #pragma GCC visibility does not override class member specific settings. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-assembler "\\.internal.*Foo.methodEv" } } */
+
+#pragma GCC visibility push(hidden)
+class Foo
+{
+ __attribute__ ((visibility ("internal"))) void method();
+};
+#pragma GCC visibility pop
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/pragma.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/pragma.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,13 @@
+/* Test that #pragma GCC visibility affects class members. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "_ZN3Foo6methodEv" } } */
+
+#pragma GCC visibility push(hidden)
+class Foo
+{
+ void method();
+};
+#pragma GCC visibility pop
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/staticmemfuncts.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,11 @@
+/* Test that setting visibility for static class member functions works. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "_ZN3Foo6methodEv" } } */
+
+class __attribute__ ((visibility ("hidden"))) Foo
+{
+ static void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/virtual.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/virtual.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/virtual.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/virtual.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,11 @@
+/* Test that setting visibility for class affects virtual table. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "ZTV3Foo" } } */
+
+class __attribute__ ((visibility ("hidden"))) Foo
+{
+ virtual void method();
+};
+
+void Foo::method() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-1.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,8 @@
+/* Test visibility attribute on function definition. */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "_Z3foov" } } */
+
+void
+__attribute__((visibility ("hidden")))
+foo()
+{ }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-2.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,7 @@
+/* Test that visibility attribute on declaration extends to definition. */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "_Z3foov" } } */
+
+void __attribute__((visibility ("hidden"))) foo();
+
+void foo() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-3.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,7 @@
+/* Test visibility attribute on forward declaration of global variable */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "xyzzy" } } */
+
+int
+__attribute__((visibility ("hidden")))
+xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-4.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,8 @@
+/* Test visibility attribute on forward declaration of global variable */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "xyzzy" } } */
+
+extern int __attribute__ ((visibility ("hidden")))
+xyzzy;
+
+int xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-5.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,11 @@
+/* Test visibility attribute on definition of a function that has
+ already had a forward declaration. */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "_Z3foov" } } */
+
+void foo();
+
+void
+ __attribute__((visibility ("hidden")))
+foo()
+{ }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-6.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,10 @@
+/* Test visibility attribute on definition of global variable that has
+ already had a forward declaration. */
+/* { dg-require-visibility "" }
+/* { dg-final { scan-hidden "xyzzy" } } */
+
+extern int xyzzy;
+
+int
+__attribute__((visibility ("hidden")))
+xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility/visibility-7.C 2006-02-10 01:38:18.000000000 -0500
@@ -0,0 +1,11 @@
+/* Test warning from conflicting visibility specifications. */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-hidden "xyzzy" } } */
+
+extern int
+__attribute__((visibility ("hidden")))
+xyzzy; /* { dg-warning "previous declaration here" "" } */
+
+int
+__attribute__((visibility ("protected")))
+xyzzy = 5; /* { dg-warning "visibility attribute ignored" "" } */
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-1.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-1.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-1.C 2003-12-10 01:34:44.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-1.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,8 +0,0 @@
-/* Test visibility attribute on function definition. */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */
-
-void
-__attribute__((visibility ("hidden")))
-foo()
-{ }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-2.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-2.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-2.C 2003-12-10 01:34:44.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-2.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,7 +0,0 @@
-/* Test that visibility attribute on declaration extends to definition. */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */
-
-void __attribute__((visibility ("hidden"))) foo();
-
-void foo() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-3.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-3.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-3.C 2003-12-10 01:34:45.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-3.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,7 +0,0 @@
-/* Test visibility attribute on forward declaration of global variable */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */
-
-int
-__attribute__((visibility ("hidden")))
-xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-4.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-4.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-4.C 2003-12-10 01:34:45.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-4.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,8 +0,0 @@
-/* Test visibility attribute on forward declaration of global variable */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */
-
-extern int __attribute__ ((visibility ("hidden")))
-xyzzy;
-
-int xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-5.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-5.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-5.C 2003-12-10 01:34:45.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-5.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,11 +0,0 @@
-/* Test visibility attribute on definition of a function that has
- already had a forward declaration. */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*_Z3foov" } } */
-
-void foo();
-
-void
- __attribute__((visibility ("hidden")))
-foo()
-{ }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-6.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-6.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-6.C 2003-12-10 01:34:45.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-6.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,10 +0,0 @@
-/* Test visibility attribute on definition of global variable that has
- already had a forward declaration. */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */
-
-extern int xyzzy;
-
-int
-__attribute__((visibility ("hidden")))
-xyzzy = 5;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-7.C gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-7.C
--- gcc-3.4.4.orig/gcc/testsuite/g++.dg/ext/visibility-7.C 2003-12-10 01:34:45.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/g++.dg/ext/visibility-7.C 1969-12-31 19:00:00.000000000 -0500
@@ -1,11 +0,0 @@
-/* Test warning from conflicting visibility specifications. */
-/* { dg-do compile { target *86-*-linux* } } */
-/* { dg-final { scan-assembler "\\.hidden.*xyzzy" } } */
-
-extern int
-__attribute__((visibility ("hidden")))
-xyzzy; /* { dg-warning "previous declaration here" "" } */
-
-int
-__attribute__((visibility ("protected")))
-xyzzy = 5; /* { dg-warning "visibility attribute ignored" "" } */
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.cc gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.cc
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.cc 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.cc 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,16 @@
+#pragma GCC visibility push(default)
+template<typename CharT>
+struct VisTest
+{
+ inline VisTest ();
+};
+template<typename CharT>
+inline VisTest<CharT>::VisTest()
+{}
+extern template class VisTest<char>;
+#pragma GCC visibility pop
+int some_function( int do_something )
+{
+ VisTest<char> a;
+ return 0;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.x gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.x
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.x 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-1.x 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,9 @@
+if ![is-shared-library-supported] {
+ return
+}
+
+#
+# build shared libray
+#
+gcc-special-compile $srcdir/$subdir/inline-hidden-1.cc \
+ "-shared -fPIC -fvisibility-inlines-hidden" "" "no"
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.cc gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.cc
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.cc 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.cc 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,14 @@
+template<typename CharT>
+struct VisTest
+{
+ inline VisTest ();
+};
+template<typename CharT>
+inline VisTest<CharT>::VisTest()
+{}
+extern template class VisTest<char>;
+int some_function( int do_something )
+{
+ VisTest<char> a;
+ return 0;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.x gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.x
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.x 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-2.x 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,9 @@
+if ![is-shared-library-supported] {
+ return
+}
+
+#
+# build shared libray
+#
+gcc-special-compile $srcdir/$subdir/inline-hidden-2.cc \
+ "-shared -fPIC -fvisibility-inlines-hidden" "" "yes"
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3.x gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3.x
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3.x 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3.x 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,11 @@
+if ![is-shared-library-supported] {
+ return
+}
+
+#
+# build shared libray
+#
+set obj [gcc-special-compile "$srcdir/$subdir/inline-hidden-3a.cc" \
+ "-fPIC -fvisibility-inlines-hidden" "" "no"]
+gcc-special-compile $srcdir/$subdir/inline-hidden-3b.cc \
+ "-shared -fPIC" "$obj" "no"
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3a.cc gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3a.cc
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3a.cc 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3a.cc 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,14 @@
+template<typename CharT>
+struct VisTest
+{
+ inline VisTest ();
+};
+template<typename CharT>
+inline VisTest<CharT>::VisTest()
+{}
+extern template class VisTest<char>;
+int some_function( int do_something )
+{
+ VisTest<char> a;
+ return 0;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3b.cc gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3b.cc
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3b.cc 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/inline-hidden-3b.cc 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,9 @@
+template<typename CharT>
+struct VisTest
+{
+ inline VisTest ();
+};
+template<typename CharT>
+inline VisTest<CharT>::VisTest()
+{}
+template class VisTest<char>;
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/special.exp gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/special.exp
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/g++.special/special.exp 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/g++.special/special.exp 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,30 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib gcc-special.exp
+
+#
+# run special tests
+#
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.x]] {
+ source $src
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-dso.c gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-dso.c
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-dso.c 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-dso.c 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,13 @@
+void
+__attribute__ ((visibility ("protected")))
+foo ()
+{
+}
+
+void (*foo_p) () = foo;
+
+void *
+bar (void)
+{
+ return foo;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-main.c gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-main.c
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-main.c 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1-main.c 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,14 @@
+extern void (*foo_p) (void);
+extern void foo (void);
+extern void* bar (void);
+
+int
+main ()
+{
+ void *p;
+ p = bar ();
+ if (p == foo && p == foo_p)
+ return 0;
+ else
+ return 1;
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1.x gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1.x
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1.x 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/protfunc-1.x 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,14 @@
+if ![is-shared-library-supported] {
+ return
+}
+
+#
+# build shared libray
+#
+set dso [gcc-special-compile $srcdir/$subdir/protfunc-1-dso.c \
+ "-fPIC -shared -O" "" "no"]
+
+#
+# build and run executable
+#
+gcc-special-execute $srcdir/$subdir/protfunc-1-main.c $dso "-O"
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/special.exp gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/special.exp
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/gcc.special/special.exp 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/gcc.special/special.exp 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,30 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# load support procs
+load_lib gcc-special.exp
+
+#
+# run special tests
+#
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.x]] {
+ source $src
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/lib/gcc-special.exp gcc-3.4.4/gcc/testsuite/gcc/testsuite/lib/gcc-special.exp
--- gcc-3.4.4.orig/gcc/testsuite/gcc/testsuite/lib/gcc-special.exp 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc/testsuite/lib/gcc-special.exp 2006-02-10 01:38:27.000000000 -0500
@@ -0,0 +1,177 @@
+# Copyright (C) 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# Based on c-torture.exp.
+
+load_lib file-format.exp
+load_lib target-supports.exp
+
+#
+# gcc-special-compile -- compile source file or build shared library.
+#
+# SRC is the full pathname of the testcase.
+# OPTIONS is the specific compiler flag we're testing (eg: -O2).
+# OBJ is the additional object.
+# XFAIL is to indicate if it should fail.
+#
+proc gcc-special-compile { src options obj xfail } {
+ global tool
+ global output
+ global srcdir tmpdir
+ global host_triplet
+
+ if [string match "yes" $xfail] {
+ setup_xfail "*-*-*"
+ }
+
+ set shared "no"
+ set option ""
+ foreach opt $options {
+ if [string match "-shared" $opt] {
+ lappend option [get-build-shared-library-option]
+ set shared "yes"
+ } elseif [string match "-fPIC" $opt] {
+ lappend option [get-compile-shared-library-option]
+ } else {
+ lappend option "$opt"
+ }
+ }
+
+ if [string match "yes" $shared] {
+ set type "executable"
+ set output "$tmpdir/[file tail [file rootname $src]].so"
+ } else {
+ set type "object"
+ set output "$tmpdir/[file tail [file rootname $src]].o"
+ }
+
+ regsub "^$srcdir/?" $src "" testcase
+ # If we couldn't rip $srcdir out of `src' then just do the best we can.
+ # The point is to reduce the unnecessary noise in the logs. Don't strip
+ # out too much because different testcases with the same name can confuse
+ # `test-tool'.
+ if [string match "/*" $testcase] {
+ set testcase "[file tail [file dirname $src]]/[file tail $src]"
+ }
+
+ verbose "Testing $testcase, $option" 1
+
+ # Run the compiler and analyze the results.
+ set options ""
+ lappend options "additional_flags=-w $option $obj"
+
+ set comp_output [${tool}_target_compile "$src" "$output" $type $options];
+ if [${tool}_check_compile $testcase $option $output $comp_output] {
+ if [string match "yes" $xfail] {
+ fail "$testcase, $option"
+ } else {
+ foreach file "$obj" {
+ remote_file build delete $file
+ }
+ }
+ } elseif [string match "yes" $xfail] {
+ foreach file "$obj" {
+ remote_file build delete $file
+ }
+ }
+ return $output
+}
+
+#
+# gcc-special-execute -- utility to compile and execute a testcase
+#
+# SOURCES is a list of full pathnames to the test source files.
+# The first filename in this list forms the "testcase".
+#
+# If the testcase has an associated .x file, we source that to run the
+# test instead. We use .x so that we don't lengthen the existing filename
+# to more than 14 chars.
+#
+proc gcc-special-execute { sources shlib additional_flags } {
+ global tmpdir tool srcdir output compiler_conditional_xfail_data
+
+ # Use the first source filename given as the filename under test.
+ set src [lindex $sources 0]
+
+ set option ""
+
+ # Check for alternate driver.
+ if [file exists [file rootname $src].x] {
+ verbose "Using alternate driver [file rootname [file tail $src]].x" 2
+ set done_p 0
+ catch "set done_p \[source [file rootname $src].x\]"
+ if { $done_p } {
+ return
+ }
+ }
+
+ set executable $tmpdir/[file tail [file rootname $src].x]
+
+ regsub "^$srcdir/?" $src "" testcase
+ # If we couldn't rip $srcdir out of `src' then just do the best we can.
+ # The point is to reduce the unnecessary noise in the logs. Don't strip
+ # out too much because different testcases with the same name can confuse
+ # `test-tool'.
+ if [string match "/*" $testcase] {
+ set testcase "[file tail [file dirname $src]]/[file tail $src]"
+ }
+
+ # torture_{compile,execute}_xfail are set by the .x script
+ # (if present)
+ if [info exists torture_compile_xfail] {
+ setup_xfail $torture_compile_xfail
+ }
+
+ # torture_execute_before_{compile,execute} can be set by the .x script
+ # (if present)
+ if [info exists torture_eval_before_compile] {
+ set ignore_me [eval $torture_eval_before_compile]
+ }
+
+ verbose "Testing $testcase, $option" 1
+
+ set options ""
+ lappend options "additional_flags=-w $option $shlib"
+ if { $additional_flags != "" } {
+ lappend options "additional_flags=$additional_flags";
+ }
+
+ set comp_output [${tool}_target_compile "$sources" "${executable}" executable $options];
+
+ if ![${tool}_check_compile "$testcase compilation" $option $executable $comp_output] {
+ unresolved "$testcase execution, $option"
+ remote_file build delete $executable
+ return
+ }
+
+ if [info exists torture_execute_xfail] {
+ setup_xfail $torture_execute_xfail
+ }
+
+ if [info exists torture_eval_before_execute] {
+ set ignore_me [eval $torture_eval_before_execute]
+ }
+
+ set result [${tool}_load "$executable" "" ""]
+ set status [lindex $result 0];
+ set output [lindex $result 1];
+ $status "$testcase execution, $option"
+ if { $status == "pass" } {
+ foreach file "$executable $shlib" {
+ remote_file build delete $file
+ }
+ }
+}
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc.dg/visibility-9.c gcc-3.4.4/gcc/testsuite/gcc.dg/visibility-9.c
--- gcc-3.4.4.orig/gcc/testsuite/gcc.dg/visibility-9.c 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc.dg/visibility-9.c 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,9 @@
+/* Test that -fvisibility works. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-options "-fvisibility=hidden" } */
+/* { dg-final { scan-assembler "\\.hidden.*foo" } } */
+
+void foo();
+
+void foo() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/gcc.dg/visibility-a.c gcc-3.4.4/gcc/testsuite/gcc.dg/visibility-a.c
--- gcc-3.4.4.orig/gcc/testsuite/gcc.dg/visibility-a.c 1969-12-31 19:00:00.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/gcc.dg/visibility-a.c 2006-02-10 01:38:13.000000000 -0500
@@ -0,0 +1,10 @@
+/* Test that #pragma GCC visibility works. */
+/* { dg-do compile } */
+/* { dg-require-visibility "" } */
+/* { dg-final { scan-assembler "\\.hidden.*foo" } } */
+
+#pragma GCC visibility push(hidden)
+void foo();
+#pragma GCC visibility pop
+
+void foo() { }
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/lib/scanasm.exp gcc-3.4.4/gcc/testsuite/lib/scanasm.exp
--- gcc-3.4.4.orig/gcc/testsuite/lib/scanasm.exp 2004-02-12 12:48:32.000000000 -0500
+++ gcc-3.4.4/gcc/testsuite/lib/scanasm.exp 2006-02-10 01:38:18.000000000 -0500
@@ -79,6 +79,32 @@ proc scan-assembler-not { args } {
dg-scan "scan-assembler-not" 0 $testcase $output_file $args
}
+# Check that a symbol is defined as a hidden symbol in the .s file
+# produced by the compiler.
+
+proc scan-hidden { args } {
+ upvar 2 name testcase
+ set output_file "[file rootname [file tail $testcase]].s"
+
+ set symbol [lindex $args 0]
+ set args [lreplace $args 0 0 "hidden\[ \t_\]*$symbol"]
+
+ dg-scan "scan-hidden" 1 $testcase $output_file $args
+}
+
+# Check that a symbol is not defined as a hidden symbol in the .s file
+# produced by the compiler.
+
+proc scan-not-hidden { args } {
+ upvar 2 name testcase
+ set output_file "[file rootname [file tail $testcase]].s"
+
+ set symbol [lindex $args 0]
+ set args [lreplace $args 0 0 "hidden\[ \t_\]*$symbol"]
+
+ dg-scan "scan-not-hidden" 0 $testcase $output_file $args
+}
+
# Look for a pattern in OUTPUT_FILE. See dg-scan for details.
proc scan-file { output_file args } {
diff -Nurp gcc-3.4.4.orig/gcc/testsuite/lib/target-supports.exp gcc-3.4.4/gcc/testsuite/lib/target-supports.exp
--- gcc-3.4.4.orig/gcc/testsuite/lib/target-supports.exp 2004-08-23 14:03:13.000000000 -0400
+++ gcc-3.4.4/gcc/testsuite/lib/target-supports.exp 2006-02-10 01:38:27.000000000 -0500
@@ -289,3 +289,53 @@ proc check_vmx_hw_available { } {
return $vmx_hw_available_saved
}
+
+# Return 1 if the target support shared library.
+
+proc is-shared-library-supported { } {
+ # Shared library is only supported on a couple of ELF platforms.
+ if { ![istarget hppa*64*-*-hpux*] \
+ && ![istarget hppa*-*-linux*] \
+ && ![istarget i?86-*-sysv4*] \
+ && ![istarget i?86-*-unixware] \
+ && ![istarget i?86-*-elf*] \
+ && ![istarget i?86-*-linux*] \
+ && ![istarget ia64-*-elf*] \
+ && ![istarget ia64-*-linux*] \
+ && ![istarget m68k-*-linux*] \
+ && ![istarget mips*-*-irix5*] \
+ && ![istarget mips*-*-linux*] \
+ && ![istarget powerpc-*-elf*] \
+ && ![istarget powerpc-*-linux*] \
+ && ![istarget powerpc-*-sysv4*] \
+ && ![istarget sparc*-*-elf] \
+ && ![istarget sparc*-*-solaris2*] \
+ && ![istarget sparc*-*-linux*] \
+ && ![istarget arm*-*-linux*] \
+ && ![istarget alpha*-*-linux*] \
+ && ![istarget s390*-*-linux*] \
+ && ![istarget x86_64-*-linux*] } {
+ return 0
+ }
+
+ if { [istarget *-*-linux*aout*] \
+ || [istarget *-*-linux*oldld*] } {
+ return 0
+ }
+
+ return 1
+}
+
+# Return gcc option to compile .o file for shared library.
+
+proc get-compile-shared-library-option { } {
+ set picflag "-fPIC"
+ return $picflag
+}
+
+# Return gcc option to build shared library.
+
+proc get-build-shared-library-option { } {
+ set ldflag "-shared"
+ return $ldflag
+}
diff -Nurp gcc-3.4.4.orig/gcc/tree.c gcc-3.4.4/gcc/tree.c
--- gcc-3.4.4.orig/gcc/tree.c 2004-08-23 14:02:41.000000000 -0400
+++ gcc-3.4.4/gcc/tree.c 2006-02-10 01:38:12.000000000 -0500
@@ -2563,6 +2563,11 @@ build_decl (enum tree_code code, tree na
layout_decl (t, 0);
else if (code == FUNCTION_DECL)
DECL_MODE (t) = FUNCTION_MODE;
+
+ /* Set default visibility to whatever the user supplied with
+ visibility_specified depending on #pragma GCC visibility. */
+ DECL_VISIBILITY (t) = default_visibility;
+ DECL_VISIBILITY_SPECIFIED (t) = visibility_options.inpragma;
return t;
}
diff -Nurp gcc-3.4.4.orig/gcc/tree.h gcc-3.4.4/gcc/tree.h
--- gcc-3.4.4.orig/gcc/tree.h 2005-01-16 11:01:19.000000000 -0500
+++ gcc-3.4.4/gcc/tree.h 2006-02-10 01:38:12.000000000 -0500
@@ -1499,6 +1499,10 @@ struct tree_type GTY(())
/* Value of the decls's visibility attribute */
#define DECL_VISIBILITY(NODE) (DECL_CHECK (NODE)->decl.visibility)
+/* Nonzero means that the decl had its visibility specified rather than
+ being inferred. */
+#define DECL_VISIBILITY_SPECIFIED(NODE) (DECL_CHECK (NODE)->decl.visibility_specified)
+
/* In a FUNCTION_DECL, nonzero if the function cannot be inlined. */
#define DECL_UNINLINABLE(NODE) (FUNCTION_DECL_CHECK (NODE)->decl.uninlinable)
@@ -1633,7 +1637,8 @@ struct tree_type GTY(())
|| TREE_CODE (DECL_CONTEXT (EXP)) == TRANSLATION_UNIT_DECL)
/* Enumerate visibility settings. */
-
+#ifndef SYMBOL_VISIBILITY_DEFINED
+#define SYMBOL_VISIBILITY_DEFINED
enum symbol_visibility
{
VISIBILITY_DEFAULT,
@@ -1641,6 +1646,7 @@ enum symbol_visibility
VISIBILITY_HIDDEN,
VISIBILITY_PROTECTED
};
+#endif
struct function;
@@ -1684,8 +1690,7 @@ struct tree_decl GTY(())
unsigned thread_local_flag : 1;
unsigned declared_inline_flag : 1;
ENUM_BITFIELD(symbol_visibility) visibility : 2;
- unsigned unused : 1;
- /* one unused bit. */
+ unsigned visibility_specified : 1;
unsigned lang_flag_0 : 1;
unsigned lang_flag_1 : 1;
diff -Nurp gcc-3.4.4.orig/gcc/varasm.c gcc-3.4.4/gcc/varasm.c
--- gcc-3.4.4.orig/gcc/varasm.c 2005-03-02 15:57:48.000000000 -0500
+++ gcc-3.4.4/gcc/varasm.c 2006-02-10 01:38:12.000000000 -0500
@@ -5211,8 +5211,8 @@ default_binds_local_p_1 (tree exp, int s
/* Static variables are always local. */
else if (! TREE_PUBLIC (exp))
local_p = true;
- /* A variable is local if the user tells us so. */
- else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
+ /* A variable is local if the user explicitly tells us so. */
+ else if (DECL_VISIBILITY_SPECIFIED (exp) && DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
local_p = true;
/* Otherwise, variables defined outside this object may not be local. */
else if (DECL_EXTERNAL (exp))
@@ -5220,6 +5220,9 @@ default_binds_local_p_1 (tree exp, int s
/* Linkonce and weak data are never local. */
else if (DECL_ONE_ONLY (exp) || DECL_WEAK (exp))
local_p = false;
+ /* If none of the above and visibility is not default, make local. */
+ else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
+ local_p = true;
/* If PIC, then assume that any global name can be overridden by
symbols resolved from other modules. */
else if (shlib)
diff -Nurp gcc-3.4.4.orig/libstdc++-v3/include/bits/allocator.h gcc-3.4.4/libstdc++-v3/include/bits/allocator.h
--- gcc-3.4.4.orig/libstdc++-v3/include/bits/allocator.h 2004-03-18 12:36:46.000000000 -0500
+++ gcc-3.4.4/libstdc++-v3/include/bits/allocator.h 2006-02-10 01:38:24.000000000 -0500
@@ -51,6 +51,8 @@
// Define the base class to std::allocator.
#include <bits/c++allocator.h>
+#pragma GCC visibility push(default)
+
namespace std
{
template<typename _Tp>
@@ -127,4 +129,6 @@ namespace std
#undef ___glibcxx_base_allocator
} // namespace std
+#pragma GCC visibility pop
+
#endif
diff -Nurp gcc-3.4.4.orig/libstdc++-v3/include/bits/basic_string.h gcc-3.4.4/libstdc++-v3/include/bits/basic_string.h
--- gcc-3.4.4.orig/libstdc++-v3/include/bits/basic_string.h 2005-04-25 07:02:01.000000000 -0400
+++ gcc-3.4.4/libstdc++-v3/include/bits/basic_string.h 2006-02-10 01:38:24.000000000 -0500
@@ -45,6 +45,8 @@
#include <bits/atomicity.h>
#include <debug/debug.h>
+#pragma GCC visibility push(default)
+
namespace std
{
/**
@@ -2362,4 +2364,6 @@ namespace std
basic_string<_CharT, _Traits, _Alloc>& __str);
} // namespace std
+#pragma GCC visibility pop
+
#endif /* _BASIC_STRING_H */
diff -Nurp gcc-3.4.4.orig/libstdc++-v3/include/std/std_fstream.h gcc-3.4.4/libstdc++-v3/include/std/std_fstream.h
--- gcc-3.4.4.orig/libstdc++-v3/include/std/std_fstream.h 2004-09-19 07:26:46.000000000 -0400
+++ gcc-3.4.4/libstdc++-v3/include/std/std_fstream.h 2006-02-10 01:38:24.000000000 -0500
@@ -49,6 +49,8 @@
#include <bits/basic_file.h>
#include <bits/gthr.h>
+#pragma GCC visibility push(default)
+
namespace std
{
// [27.8.1.1] template class basic_filebuf
@@ -840,4 +842,6 @@ namespace std
# include <bits/fstream.tcc>
#endif
+#pragma GCC visibility pop
+
#endif /* _GLIBCXX_FSTREAM */
diff -Nurp gcc-3.4.4.orig/libstdc++-v3/include/std/std_istream.h gcc-3.4.4/libstdc++-v3/include/std/std_istream.h
--- gcc-3.4.4.orig/libstdc++-v3/include/std/std_istream.h 2004-02-11 10:02:03.000000000 -0500
+++ gcc-3.4.4/libstdc++-v3/include/std/std_istream.h 2006-02-10 01:38:24.000000000 -0500
@@ -45,6 +45,8 @@
#include <ios>
#include <limits> // For numeric_limits
+#pragma GCC visibility push(default)
+
namespace std
{
// [27.6.1.1] Template class basic_istream
@@ -771,4 +773,6 @@ namespace std
# include <bits/istream.tcc>
#endif
+#pragma GCC visibility pop
+
#endif /* _GLIBCXX_ISTREAM */
diff -Nurp gcc-3.4.4.orig/libstdc++-v3/include/std/std_ostream.h gcc-3.4.4/libstdc++-v3/include/std/std_ostream.h
--- gcc-3.4.4.orig/libstdc++-v3/include/std/std_ostream.h 2004-02-11 10:02:03.000000000 -0500
+++ gcc-3.4.4/libstdc++-v3/include/std/std_ostream.h 2006-02-10 01:38:24.000000000 -0500
@@ -44,6 +44,8 @@
#include <ios>
+#pragma GCC visibility push(default)
+
namespace std
{
// [27.6.2.1] Template class basic_ostream
@@ -545,4 +547,6 @@ namespace std
# include <bits/ostream.tcc>
#endif
+#pragma GCC visibility pop
+
#endif /* _GLIBCXX_OSTREAM */