summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-08-25 20:21:25 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-08-25 20:21:25 +0200
commitc5616014bb288b89610b8b59b9515a06577a8c41 (patch)
tree659be749aa3af8f7ba787bb9aee99db4f217bc27 /compilerplugins
parent682f05f0b04f0f6949fbd220140964006dd7cbe6 (diff)
loplugin:redundantcast: suppress warnings in reworked glibc assert macro
Change-Id: I20be230b3ff5d11395f33a9896d0a575c3051fb7
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/redundantcast.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx
index 03e48f8fe261..19393e0c6449 100644
--- a/compilerplugins/clang/redundantcast.cxx
+++ b/compilerplugins/clang/redundantcast.cxx
@@ -439,6 +439,20 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) {
{
return true;
}
+ // Suppress warnings from static_cast<bool> in C++ definition of assert in
+ // <https://sourceware.org/git/?p=glibc.git;a=commit;
+ // h=b5889d25e9bf944a89fdd7bcabf3b6c6f6bb6f7c> "assert: Support types
+ // without operator== (int) [BZ #21972]":
+ if (t1->isBooleanType() && t2->isBooleanType()) {
+ auto loc = expr->getLocStart();
+ if (compiler.getSourceManager().isMacroBodyExpansion(loc)
+ && (Lexer::getImmediateMacroName(
+ loc, compiler.getSourceManager(), compiler.getLangOpts())
+ == "assert"))
+ {
+ return true;
+ }
+ }
report(
DiagnosticsEngine::Warning,
("static_cast from %0 %1 to %2 %3 is redundant%select{| or should be"