summaryrefslogtreecommitdiffstats
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-02-16 17:56:08 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-02-16 17:56:08 +0100
commitbe067003098c9a9537b713742d14d8f502a9c0b7 (patch)
tree7fd74fcbfcd297d4e8461ac82fd0935ba59b8371 /compilerplugins
parentloplugin:redundantcast: Avoid double warnings on some const_cast (diff)
downloadcore-be067003098c9a9537b713742d14d8f502a9c0b7.tar.gz
core-be067003098c9a9537b713742d14d8f502a9c0b7.zip
Silence loplugin:redundantcast false warning
...that is curiously only reported when building with clang -std=gnu++17: > sc/qa/unit/ucalc_condformat.cxx:185:80: error: redundant const_cast from 'ScConditionalFormat *' to 'const ScConditionalFormat *', result is implictly cast to 'const ScConditionalFormat *const' [loplugin:redundantcast] > CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong conditional format instance.", pCheck, const_cast<const ScConditionalFormat*>(pFormat)); > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:230:32: note: expanded from macro 'CPPUNIT_ASSERT_EQUAL_MESSAGE' > (actual), \ > ~^~~~~~~ > 1 error generated. > make[1]: *** [solenv/gbuild/LinkTarget.mk:270: workdir/CxxObject/sc/qa/unit/ucalc_condformat.o] Error 1 Change-Id: If2e8577bad4ec7454d584eb59106734d47f876ad
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/redundantcast.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index c7561a7a6bae..0525fa51f584 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -176,11 +176,13 @@ bool RedundantCast::VisitImplicitCastExpr(const ImplicitCastExpr * expr) {
expr->getSubExpr()->IgnoreParenImpCasts());
if (e != nullptr && !isRedundantConstCast(e)) {
auto t1 = e->getSubExpr()->getType().getCanonicalType();
- auto t2 = expr->getType().getCanonicalType();
+ auto t3 = expr->getType().getCanonicalType();
bool ObjCLifetimeConversion;
- if (t1.getTypePtr() == t2.getTypePtr()
- || compiler.getSema().IsQualificationConversion(
- t1, t2, false, ObjCLifetimeConversion))
+ if (t1.getTypePtr() == t3.getTypePtr()
+ || (compiler.getSema().IsQualificationConversion(
+ t1, t3, false, ObjCLifetimeConversion)
+ && (e->getType().getCanonicalType().getTypePtr()
+ != t3.getTypePtr())))
{
report(
DiagnosticsEngine::Warning,