diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-06-29 15:58:10 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-06-29 23:41:00 +0200 |
commit | 15e51fbc5710ef40506645b34a3fe17de3ce511f (patch) | |
tree | 39e195727a1a6748631e3abff28ea7ca9d4c205c | |
parent | 48cb5c72219b6c1c44974459876af988c0991f18 (diff) |
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 <sbergman@redhat.com>
-rw-r--r-- | compilerplugins/clang/check.cxx | 2 | ||||
-rw-r--r-- | compilerplugins/clang/test/redundantcast.cxx | 3 |
2 files changed, 4 insertions, 1 deletions
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() { |