diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-12-05 11:37:59 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-12-05 18:11:15 +0100 |
commit | 306ddfb1b87d94a343e8e2b6b9270ca682f92ac3 (patch) | |
tree | ef46ec8bc63d3db71ebe17a571ec8f9787d6c814 /compilerplugins/clang/test/redundantcast.cxx | |
parent | 36c9eddf44b302bf1e9a9b88af8f89d3e2012df2 (diff) |
Replace deprecated std::mem_fun et al in reportdesign
(as std::mem_fun is gone by default at least from recent libc++ in C++17 mode)
Change-Id: Ib66134bd4072dfe0ce3bc36aa684cee710921235
Reviewed-on: https://gerrit.libreoffice.org/45868
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/test/redundantcast.cxx')
-rw-r--r-- | compilerplugins/clang/test/redundantcast.cxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index 20578079c2cb..70fcdf3340cb 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -340,6 +340,40 @@ void testDynamicCast() { (void) dynamic_cast<S3 *>(s2); } +void overload(int); +void overload(long); +void nonOverload(); + +struct Overload { + int overload(); + long overload() const; + void nonOverload(); +}; + +void testOverloadResolution() { + (void) static_cast<void (*)(long)>(overload); + (void) static_cast<void (*)(long)>((overload)); + (void) static_cast<void (*)(long)>(&overload); + (void) static_cast<void (*)(long)>((&overload)); + (void) static_cast<void (*)(long)>(&((overload))); + (void) static_cast<void (*)()>(nonOverload); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>((nonOverload)); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>(&nonOverload); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>((&nonOverload)); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<void (*)()>(&((nonOverload))); // expected-error {{static_cast from 'void (*)()' prvalue to 'void (*)()' prvalue is redundant [loplugin:redundantcast]}} + (void) static_cast<long (Overload::*)() const>(&Overload::overload); + (void) static_cast<void (Overload::*)()>(&Overload::nonOverload); // expected-error {{static_cast from 'void (Overload::*)()' prvalue to 'void (Overload::*)()' prvalue is redundant [loplugin:redundantcast]}} + + using OverloadFn = void (*)(long); + (void) OverloadFn(overload); + using NonOverloadFn = void (*)(); + (void) NonOverloadFn(nonOverload); // expected-error {{redundant functional cast from 'void (*)()' to 'NonOverloadFn' (aka 'void (*)()') [loplugin:redundantcast]}} + using OverloadMemFn = long (Overload::*)() const; + (void) OverloadMemFn(&Overload::overload); + using NonOverloadMemFn = void (Overload::*)(); + (void) NonOverloadMemFn(&Overload::nonOverload); // expected-error {{redundant functional cast from 'void (Overload::*)()' to 'NonOverloadMemFn' (aka 'void (Overload::*)()') [loplugin:redundantcast]}} +}; + int main() { testConstCast(); testStaticCast(); |