compilerplugins/clang/test/redundantcast.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
New commits: commit 5872221094834af8553b3a7028d52f26dda391fa Author: Stephan Bergmann <sberg...@redhat.com> Date: Fri Jun 2 10:39:28 2017 +0200 Reorganize tests Change-Id: Ic3d9e55b2730a3ea01cc6c7c9fbdd80a1e653c7e diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx index ddf525ae9f0c..6e5a8d42e589 100644 --- a/compilerplugins/clang/test/redundantcast.cxx +++ b/compilerplugins/clang/test/redundantcast.cxx @@ -14,7 +14,7 @@ void f2(char const *) {} enum Enum1 { X }; -int main() { +void testConstCast() { char * p1; char const * p2; p1 = nullptr; @@ -32,15 +32,14 @@ int main() { f2(const_cast<char const *>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *' [loplugin:redundantcast]}} f2(const_cast<char const * const>(p2)); // expected-error {{redundant const_cast from 'const char *' to 'const char *const' [loplugin:redundantcast]}} - Enum1 e = (Enum1)Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}} - (void)e; - S const s{}; const_cast<S &>(s).f1(); const_cast<S &>(s).f2(); // expected-error {{redundant const_cast from 'const S' to 'S', result is implicitly cast to 'const S' [loplugin:redundantcast]}} const_cast<S &>(s).f3(); s.f3(); +} +void testStaticCast() { // non-class lvalue, non-const: int ni{}; (void) static_cast<int>(ni); // expected-error {{static_cast from 'int' lvalue to 'int' prvalue is redundant or should be written as an explicit construction of a temporary [loplugin:redundantcast]}} @@ -174,4 +173,15 @@ int main() { (void) static_cast<S const &&>(csr()); } +void testCStyleCast() { + Enum1 e = (Enum1)Enum1::X; // expected-error {{redundant cstyle cast from 'Enum1' to 'Enum1' [loplugin:redundantcast]}} + (void)e; +} + +int main() { + testConstCast(); + testStaticCast(); + testCStyleCast(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits