compilerplugins/clang/check.cxx              |    2 +-
 compilerplugins/clang/test/redundantcast.cxx |    3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 15e51fbc5710ef40506645b34a3fe17de3ce511f
Author: Stephan Bergmann <sberg...@redhat.com>
Date:   Fri Jun 29 15:58:10 2018 +0200

    Improved loplugin:redundantcast (const-qualified typedefs)
    
    ...see comments to <https://gerrit.libreoffice.org/#/c/56661/> "This cast 
seems
    completely unnecessary to me?"
    
    Change-Id: I57d27cd2aa2dc94bc2e0b49fe06a09d31301cb7e
    Reviewed-on: https://gerrit.libreoffice.org/56708
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/compilerplugins/clang/check.cxx b/compilerplugins/clang/check.cxx
index 2f1ca066452f..b31e40b23e2b 100644
--- a/compilerplugins/clang/check.cxx
+++ b/compilerplugins/clang/check.cxx
@@ -268,7 +268,7 @@ bool isOkToRemoveArithmeticCast(
     // suffix like L it could still be either long or long long):
     if ((t1->isIntegralType(context)
          || t1->isRealFloatingType())
-        && ((t1 != t2
+        && ((t1.getLocalUnqualifiedType() != t2.getLocalUnqualifiedType()
              && (loplugin::TypeCheck(t1).Typedef()
                  || loplugin::TypeCheck(t2).Typedef()))
             || isArithmeticOp(subExpr)
diff --git a/compilerplugins/clang/test/redundantcast.cxx 
b/compilerplugins/clang/test/redundantcast.cxx
index 713a3be1433c..3aae140d77f0 100644
--- a/compilerplugins/clang/test/redundantcast.cxx
+++ b/compilerplugins/clang/test/redundantcast.cxx
@@ -318,6 +318,9 @@ void testArithmeticTypedefs() {
     (void) static_cast<T1>(nt1r()); // expected-error {{redundant}}
     (void) T1(nt1r()); // expected-error {{redundant}}
     (void) (T1) nt1r(); // expected-error {{redundant}}
+
+    T1 const c{};
+    (void) static_cast<T1>(c); // expected-error {{redundant}}
 }
 
 void testReinterpretConstCast() {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to