* target-def.h (TARGET_CXX): Add TARGET_CXX_EXPORT_CLASS_DATA.
* target.h (cxx): Add export_class_data.
* config/arm/arm.c (arm_cxx_export_class_data): New function.
(TARGET_CXX_EXPORT_CLASS_DATA): Use it.
* testsuite/g++.dg/ext/visibility/arm1.C: New test.
* cp-tree.h (DECL_CONSTRUCTION_VTABLE_P): New macro.
* class.c (build_ctor_vtbl_group): Set DECL_CONSTRUCTION_VTABLE_P.
* decl2.c (determine_visibility): Honor
TARGET_CXX_EXPORT_CLASS_DATA.
* g++.dg/ext/visibility/arm1.C: New test.
From-SVN: r86867
+2004-08-31 Mark Mitchell <mark@codesourcery.com>
+
+ * target-def.h (TARGET_CXX): Add TARGET_CXX_EXPORT_CLASS_DATA.
+ * target.h (cxx): Add export_class_data.
+ * config/arm/arm.c (arm_cxx_export_class_data): New function.
+ (TARGET_CXX_EXPORT_CLASS_DATA): Use it.
+ * testsuite/g++.dg/ext/visibility/arm1.C: New test.
+
2004-08-31 Kaz Kojima <kkojima@gcc.gnu.org>
* config/sh/sh.c (output_branch): Check the insn length possibly
static tree arm_get_cookie_size (tree);
static bool arm_cookie_has_size (void);
static bool arm_cxx_cdtor_returns_this (void);
+static bool arm_cxx_key_method_may_be_inline (void);
+static bool arm_cxx_export_class_data (void);
static void arm_init_libfuncs (void);
\f
#undef TARGET_CXX_CDTOR_RETURNS_THIS
#define TARGET_CXX_CDTOR_RETURNS_THIS arm_cxx_cdtor_returns_this
+#undef TARGET_CXX_KEY_METHOD_MAY_BE_INLINE
+#define TARGET_CXX_KEY_METHOD_MAY_BE_INLINE arm_cxx_key_method_may_be_inline
+
+#undef TARGET_CXX_EXPORT_CLASS_DATA
+#define TARGET_CXX_EXPORT_CLASS_DATA arm_cxx_export_class_data
+
struct gcc_target targetm = TARGET_INITIALIZER;
\f
/* Obstack for minipool constant handling. */
return TARGET_AAPCS_BASED;
}
+/* The EABI says that an inline function may never be the key
+ method. */
+
+static bool
+arm_cxx_key_method_may_be_inline (void)
+{
+ return !TARGET_AAPCS_BASED;
+}
+
+/* The EABI says that the virtual table, etc., for a class must be
+ exported if it has a key method. The EABI does not specific the
+ behavior if there is no key method, but there is no harm in
+ exporting the class data in that case too. */
+
+static bool
+arm_cxx_export_class_data (void)
+{
+ return TARGET_AAPCS_BASED;
+}
void
arm_set_return_address (rtx source, rtx scratch)
"%{static:-Bstatic} %{shared:-shared} %{symbolic:-Bsymbolic} " \
"-X"
-#if defined (__thumb__) && !defined (__THUMB_INTERWORK)
+#if defined (__thumb__) && !defined (__THUMB_INTERWORK__)
#define RENAME_LIBRARY_SET ".thumb_set"
#else
#define RENAME_LIBRARY_SET ".set"
2004-08-31 Mark Mitchell <mark@codesourcery.com>
+ * cp-tree.h (DECL_CONSTRUCTION_VTABLE_P): New macro.
+ * class.c (build_ctor_vtbl_group): Set DECL_CONSTRUCTION_VTABLE_P.
+ * decl2.c (determine_visibility): Honor
+ TARGET_CXX_EXPORT_CLASS_DATA.
+
* class.c (key_method): Rename to ...
(determine_key_method): ... this.
(finish_struct_1): Adjust accordingly.
constructing the addresses of secondary vtables in the
construction vtable group. */
vtbl = build_vtable (t, id, ptr_type_node);
+ DECL_CONSTRUCTION_VTABLE_P (vtbl) = 1;
list = build_tree_list (vtbl, NULL_TREE);
accumulate_vtbl_inits (binfo, TYPE_BINFO (TREE_TYPE (binfo)),
binfo, t, list);
5: C_IS_RESERVED_WORD (in IDENTIFIER_NODE)
DECL_VTABLE_OR_VTT_P (in VAR_DECL)
6: IDENTIFIER_REPO_CHOSEN (in IDENTIFIER_NODE)
+ DECL_CONSTRUCTION_VTABLE_P (in VAR_DECL)
Usage of TYPE_LANG_FLAG_?:
0: TYPE_DEPENDENT_P
/* 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))
+/* Returns 1 iff VAR_DECL is a construction virtual table.
+ DECL_VTABLE_OR_VTT_P will be true in this case and must be checked
+ before using this macro. */
+#define DECL_CONSTRUCTION_VTABLE_P(NODE) \
+ TREE_LANG_FLAG_6 (VAR_DECL_CHECK (NODE))
+
/* 1 iff NODE is function-local, but for types. */
#define LOCAL_CLASS_P(NODE) \
(decl_function_context (TYPE_MAIN_DECL (NODE)) != NULL_TREE)
the visibility of their containing class. */
if (class_type)
{
- if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
- && lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type)))
+ if (targetm.cxx.export_class_data ()
+ && (DECL_TINFO_P (decl)
+ || (DECL_VTABLE_OR_VTT_P (decl)
+ /* Construction virtual tables are not emitted
+ because they cannot be referred to from other
+ object files; their name is not standardized by
+ the ABI. */
+ && !DECL_CONSTRUCTION_VTABLE_P (decl))))
+ DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
+ else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
+ && lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type)))
{
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
DECL_VISIBILITY_SPECIFIED (decl) = 1;
- return;
}
-
- if (TREE_CODE (decl) == FUNCTION_DECL
- && DECL_DECLARED_INLINE_P (decl)
- && visibility_options.inlines_hidden)
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && DECL_DECLARED_INLINE_P (decl)
+ && visibility_options.inlines_hidden)
{
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
DECL_VISIBILITY_SPECIFIED (decl) = 1;
method. The default is to return @code{true}.
@end deftypefn
+@deftypefn {Target Hook} bool TARGET_CXX_EXPORT_CLASS_DATA (void)
+If this hook returns false (the default), then virtual tables and RTTI
+data structures will have the ELF visibility of their containing
+class. If this hook returns true, then these data structures will
+have ELF ``default'' visibility, independently of the visibility of
+the containing class.
+@end deftypefn
+
@node Misc
@section Miscellaneous Parameters
@cindex parameters, miscellaneous
#define TARGET_CXX_KEY_METHOD_MAY_BE_INLINE hook_bool_void_true
#endif
-#define TARGET_CXX \
- { \
- TARGET_CXX_GUARD_TYPE, \
- TARGET_CXX_GUARD_MASK_BIT, \
- TARGET_CXX_GET_COOKIE_SIZE, \
- TARGET_CXX_COOKIE_HAS_SIZE, \
- TARGET_CXX_IMPORT_EXPORT_CLASS, \
- TARGET_CXX_CDTOR_RETURNS_THIS, \
- TARGET_CXX_KEY_METHOD_MAY_BE_INLINE \
+#ifndef TARGET_CXX_EXPORT_CLASS_DATA
+#define TARGET_CXX_EXPORT_CLASS_DATA hook_bool_void_false
+#endif
+
+#define TARGET_CXX \
+ { \
+ TARGET_CXX_GUARD_TYPE, \
+ TARGET_CXX_GUARD_MASK_BIT, \
+ TARGET_CXX_GET_COOKIE_SIZE, \
+ TARGET_CXX_COOKIE_HAS_SIZE, \
+ TARGET_CXX_IMPORT_EXPORT_CLASS, \
+ TARGET_CXX_CDTOR_RETURNS_THIS, \
+ TARGET_CXX_KEY_METHOD_MAY_BE_INLINE, \
+ TARGET_CXX_EXPORT_CLASS_DATA \
}
/* The whole shebang. */
itself. Returning true is the behavior required by the Itanium
C++ ABI. */
bool (*key_method_may_be_inline) (void);
+ /* Returns true if all class data (virtual tables, type info,
+ etc.) should be exported from the current DLL, even when the
+ associated class is not exported. */
+ bool (*export_class_data) (void);
} cxx;
/* Leave the boolean fields at the end. */
+2004-08-31 Mark Mitchell <mark@codesourcery.com>
+
+ * g++.dg/ext/visibility/arm1.C: New test.
+
2004-08-31 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/funcdef-storage-1.c: Add dg-options to suppress