From: Danny Smith Date: Thu, 8 Apr 2004 22:31:23 +0000 (+0000) Subject: re PR c++/14808 ([win32] Undefined results with virtual base classes) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a77e08cfcde08398ad78b29fce29a531190ed52;p=gcc.git re PR c++/14808 ([win32] Undefined results with virtual base classes) PR c++/14808 * defaults.h (TARGET_USE_LOCAL_THUNK_ALIAS_P): New macro. Default to 1 if ASM_OUTPUT_DEF is defined. * doc/tm.texi (TARGET_USE_LOCAL_THUNK_ALIAS_P): Document. * config/i386/cygming.h (TARGET_USE_LOCAL_THUNK_ALIAS_P): Define. Set to non-zero iff not a one_only decl. * cp/method.c (use_thunk): Test TARGET_USE_LOCAL_THUNK_ALIAS_P rather than ASM_OUTPUT_DEF. From-SVN: r80525 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dfda231368d..aafeafa41aa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2004-04-08 Danny Smith + + PR c++/14808 + * defaults.h (TARGET_USE_LOCAL_THUNK_ALIAS_P): New macro. Default + to 1 if ASM_OUTPUT_DEF is defined. + * doc/tm.texi (TARGET_USE_LOCAL_THUNK_ALIAS_P): Document. + * config/i386/cygming.h (TARGET_USE_LOCAL_THUNK_ALIAS_P): Define. + Set to non-zero iff not a one_only decl. + 2004-04-08 Paul Brook * arm.h (CLASS_LIKELY_SPILLED_P): Define. diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h index 00628f09e2d..85027925ec1 100644 --- a/gcc/config/i386/cygming.h +++ b/gcc/config/i386/cygming.h @@ -382,6 +382,11 @@ extern int i386_pe_dllimport_name_p (const char *); ASM_OUTPUT_DEF (STREAM, alias, IDENTIFIER_POINTER (TARGET)); \ } while (0) +/* Decide whether it is safe to use a local alias for a virtual function + when constructing thunks. */ +#undef TARGET_USE_LOCAL_THUNK_ALIAS_P +#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) (!DECL_ONE_ONLY (DECL)) + #undef TREE #ifndef BUFSIZ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1873a8a20a..bfb3191e534 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-04-08 Danny Smith + + PR c++/14808 + * method.c (use_thunk): Test TARGET_USE_LOCAL_THUNK_ALIAS_P rather + than ASM_OUTPUT_DEF. + 2004-04-08 Jakub Jelinek * decl2.c (mark_used): Don't segfault if cfun != NULL but diff --git a/gcc/cp/method.c b/gcc/cp/method.c index 10dfaca6086..49ba9834d99 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -363,11 +363,10 @@ use_thunk (tree thunk_fndecl, bool emit_p) if (!emit_p) return; -#ifdef ASM_OUTPUT_DEF - alias = make_alias_for_thunk (function); -#else - alias = function; -#endif + if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function)) + alias = make_alias_for_thunk (function); + else + alias = function; fixed_offset = THUNK_FIXED_OFFSET (thunk_fndecl); virtual_offset = THUNK_VIRTUAL_OFFSET (thunk_fndecl); @@ -401,8 +400,8 @@ use_thunk (tree thunk_fndecl, bool emit_p) push_to_top_level (); -#ifdef ASM_OUTPUT_DEF - if (targetm.have_named_sections) + if (TARGET_USE_LOCAL_THUNK_ALIAS_P (function) + && targetm.have_named_sections) { resolve_unique_section (function, 0, flag_function_sections); @@ -414,7 +413,6 @@ use_thunk (tree thunk_fndecl, bool emit_p) DECL_SECTION_NAME (thunk_fndecl) = DECL_SECTION_NAME (function); } } -#endif /* The back-end expects DECL_INITIAL to contain a BLOCK, so we create one. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index e4a6fae57e5..9f261d0e0de 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -484,6 +484,16 @@ do { fputs (integer_asm_op (POINTER_SIZE / BITS_PER_UNIT, TRUE), FILE); \ #define TARGET_VTABLE_DATA_ENTRY_DISTANCE 1 #endif +/* Decide whether it is safe to use a local alias for a virtual function + when constructing thunks. */ +#ifndef TARGET_USE_LOCAL_THUNK_ALIAS_P +#ifdef ASM_OUTPUT_DEF +#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 1 +#else +#define TARGET_USE_LOCAL_THUNK_ALIAS_P(DECL) 0 +#endif +#endif + /* Select a format to encode pointers in exception handling data. We prefer those that result in fewer dynamic relocations. Assume no special support here and encode direct references. */ diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index b2fe858a013..230ee524643 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -9209,3 +9209,11 @@ The parameter @var{path} is the include to register. On Darwin systems, this is used for Framework includes, which have semantics that are different from @option{-I}. @end deftypefn + +@deftypefn {Target Hook} bool TARGET_USE_LOCAL_THUNK_ALIAS_P (tree @var{fndecl}) +This target hook returns @code{true} if it is safe to use a local alias +for a virtual function @var{fndecl} when constructing thunks, +@code{false} otherwise. By default, the hook returns @code{true} for all +functions, if a target supports aliases (ie. defines +@code{ASM_OUTPUT_DEF}), @code{false} otherwise, +@end deftypefn