diff options
author | Mark Mitchell <mark@codesourcery.com> | 2004-09-01 03:45:30 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2004-09-01 03:45:30 +0000 |
commit | 505970fc3324e2a0c00f5d82d66f62bae133e282 (patch) | |
tree | ec2aef636de8abf10479855a1221a1b908fabff6 | |
parent | be8fff8104f223a0eaa5ea36f385982d09d9731e (diff) | |
download | gcc-505970fc3324e2a0c00f5d82d66f62bae133e282.zip gcc-505970fc3324e2a0c00f5d82d66f62bae133e282.tar.gz gcc-505970fc3324e2a0c00f5d82d66f62bae133e282.tar.bz2 |
target-def.h (TARGET_CXX): Add TARGET_CXX_EXPORT_CLASS_DATA.
* 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
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 27 | ||||
-rw-r--r-- | gcc/config/arm/bpabi.h | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/class.c | 1 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 7 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 21 | ||||
-rw-r--r-- | gcc/doc/tm.texi | 8 | ||||
-rw-r--r-- | gcc/target-def.h | 23 | ||||
-rw-r--r-- | gcc/target.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 |
11 files changed, 93 insertions, 17 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 67301eb..55d646e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +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 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 9d9acb2..52566be 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -172,6 +172,8 @@ static bool arm_cxx_guard_mask_bit (void); 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); @@ -296,6 +298,12 @@ static void arm_init_libfuncs (void); #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; /* Obstack for minipool constant handling. */ @@ -14204,6 +14212,25 @@ arm_cxx_cdtor_returns_this (void) 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) diff --git a/gcc/config/arm/bpabi.h b/gcc/config/arm/bpabi.h index 4831dfb..60d6e75 100644 --- a/gcc/config/arm/bpabi.h +++ b/gcc/config/arm/bpabi.h @@ -46,7 +46,7 @@ "%{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" diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0a0fdfd..929bde0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 84c7587..957151d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6996,6 +6996,7 @@ build_ctor_vtbl_group (tree binfo, tree t) 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); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a6db553..35eb3a7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -74,6 +74,7 @@ struct diagnostic_context; 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 @@ -1992,6 +1993,12 @@ struct lang_decl GTY(()) /* 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) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d02180a..c26d48f 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -1655,17 +1655,24 @@ determine_visibility (tree decl) 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; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index d1e59cf..bba444c 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -8538,6 +8538,14 @@ some variants of the ABI, an inline function can never be the key 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 diff --git a/gcc/target-def.h b/gcc/target-def.h index e49d055..3b4c11b 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -441,15 +441,20 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #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. */ diff --git a/gcc/target.h b/gcc/target.h index 57b38cf..035aeed 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -521,6 +521,10 @@ struct gcc_target 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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 04f794b..203f6a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +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 |