diff options
author | Martin Sebor <msebor@redhat.com> | 2017-10-12 17:37:56 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2017-10-12 11:37:56 -0600 |
commit | 7a866e7e316df13b04a84a8d5426b43d016573ea (patch) | |
tree | 0aa083148a64517b691539878d5b1cfcead20175 /gcc/doc | |
parent | e95c91292876830c8e36b0a55f0c03d1247aaccb (diff) | |
download | gcc-7a866e7e316df13b04a84a8d5426b43d016573ea.zip gcc-7a866e7e316df13b04a84a8d5426b43d016573ea.tar.gz gcc-7a866e7e316df13b04a84a8d5426b43d016573ea.tar.bz2 |
PR c/82301 - Updated test case g++.dg/ext/attr-ifunc-1.C (and others) in r253041 segfault on powerpc64
PR c/82301 - Updated test case g++.dg/ext/attr-ifunc-1.C (and others) in r253041 segfault on powerpc64
PR c/82435 - new __attribute__((alias)) warning gets in the way
gcc/ChangeLog:
PR other/82301
PR c/82435
* cgraphunit.c (maybe_diag_incompatible_alias): New function.
(handle_alias_pairs): Call it.
* common.opt (-Wattribute-alias): New option.
* doc/extend.texi (ifunc attribute): Discuss C++ specifics.
* doc/invoke.texi (-Wattribute-alias): Document.
gcc/testsuite/ChangeLog:
PR other/82301
PR c/82435
* g++.dg/ext/attr-ifunc-1.C: Update.
* g++.dg/ext/attr-ifunc-2.C: Same.
* g++.dg/ext/attr-ifunc-3.C: Same.
* g++.dg/ext/attr-ifunc-4.C: Same.
* g++.dg/ext/attr-ifunc-5.C: Same.
* g++.dg/ext/attr-ifunc-6.C: New test.
* g++.old-deja/g++.abi/vtable2.C: Update.
* gcc.dg/attr-ifunc-6.c: New test.
* gcc.dg/attr-ifunc-7.c: New test.
* gcc.dg/pr81854.c: Update.
* lib/target-supports.exp: Update.
From-SVN: r253688
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/extend.texi | 49 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 5 |
2 files changed, 50 insertions, 4 deletions
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 0014490e..a196b59 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2801,7 +2801,7 @@ void *my_memcpy (void *dst, const void *src, size_t len) static void * (*resolve_memcpy (void))(void *, const void *, size_t) @{ - return my_memcpy; // we'll just always select this routine + return my_memcpy; // we will just always select this routine @} @end smallexample @@ -2814,15 +2814,56 @@ extern void *memcpy (void *, const void *, size_t); @end smallexample @noindent -allowing the user to call this as a regular function, unaware of the -implementation. Finally, the indirect function needs to be defined in -the same translation unit as the resolver function: +allowing the user to call @code{memcpy} as a regular function, unaware of +the actual implementation. Finally, the indirect function needs to be +defined in the same translation unit as the resolver function: @smallexample void *memcpy (void *, const void *, size_t) __attribute__ ((ifunc ("resolve_memcpy"))); @end smallexample +In C++, the @code{ifunc} attribute takes a string that is the mangled name +of the resolver function. A C++ resolver for a non-static member function +of class @code{C} should be declared to return a pointer to a non-member +function taking pointer to @code{C} as the first argument, followed by +the same arguments as of the implementation function. G++ checks +the signatures of the two functions and issues +a @option{-Wattribute-alias} warning for mismatches. To suppress a warning +for the necessary cast from a pointer to the implementation member function +to the type of the corresponding non-member function use +the @option{-Wno-pmf-conversions} option. For example: + +@smallexample +class S +@{ +private: + int debug_impl (int); + int optimized_impl (int); + + typedef int Func (S*, int); + + static Func* resolver (); +public: + + int interface (int); +@}; + +int S::debug_impl (int) @{ /* @r{@dots{}} */ @} +int S::optimized_impl (int) @{ /* @r{@dots{}} */ @} + +S::Func* S::resolver () +@{ + int (S::*pimpl) (int) + = getenv ("DEBUG") ? &S::debug_impl : &S::optimized_impl; + + // Cast triggers -Wno-pmf-conversions. + return reinterpret_cast<Func*>(pimpl); +@} + +int S::interface (int) __attribute__ ((ifunc ("_ZN1S8resolverEv"))); +@end smallexample + Indirect functions cannot be weak. Binutils version 2.20.1 or higher and GNU C Library version 2.11.1 are required to use this feature. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9ad1fb3..4e7dfb3 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -5402,6 +5402,11 @@ pointers. This warning level may give a larger number of false positives and is deactivated by default. @end table +@item -Wattribute-alias +Warn about declarations using the @code{alias} and similar attributes whose +target is incompatible with the type of the alias. @xref{Function Attributes, +,Declaring Attributes of Functions}. + @item -Wbool-compare @opindex Wno-bool-compare @opindex Wbool-compare |