[Libreoffice-commits] core.git: compilerplugins/clang

Stephan Bergmann sbergman at redhat.com
Wed May 31 16:05:35 UTC 2017


 compilerplugins/clang/test/redundantcast.cxx |   13 +++++++++++++
 1 file changed, 13 insertions(+)

New commits:
commit 967e9e6bbb36eb925c14b43b9baff541d82ee4c0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed May 31 18:04:22 2017 +0200

    Add some loplugin:redundantcast tests
    
    Change-Id: I5c39a745b70655f92953ec785d01a3a52d9ec42b

diff --git a/compilerplugins/clang/test/redundantcast.cxx b/compilerplugins/clang/test/redundantcast.cxx
index 9b287dac9f2e..53df00ae96ed 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -12,6 +12,13 @@ void f2(char const *) {}
 
 enum Enum1 { X };
 
+struct S {
+    void f1() { (void)*this; };
+    void f2() const { (void)*this; };
+    void f3() { (void)*this; }
+    void f3() const { (void)*this; };
+};
+
 int main() {
     char * p1;
     char const * p2;
@@ -32,6 +39,12 @@ int main() {
 
     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();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */


More information about the Libreoffice-commits mailing list