fixed/aligned some compiler warnings (#3065)

This commit is contained in:
Oliver Stöneberg 2021-01-21 18:13:32 +01:00 committed by GitHub
parent 95d1b41a5b
commit 491f4874c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 4 deletions

View File

@ -51,6 +51,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options_safe(-Wdocumentation)
add_compile_options_safe(-Wdocumentation-pedantic)
add_compile_options_safe(-Wno-documentation-unknown-command)
add_compile_options_safe(-Wimplicit-fallthrough)
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
message(FATAL_ERROR "Do not use clang for generate code coverage. Use gcc.")

View File

@ -248,6 +248,7 @@ void ProjectFile::readBuildDir(QXmlStreamReader &reader)
switch (type) {
case QXmlStreamReader::Characters:
mBuildDir = reader.text().toString();
FALLTHROUGH;
case QXmlStreamReader::EndElement:
return;
// Not handled
@ -273,6 +274,7 @@ void ProjectFile::readImportProject(QXmlStreamReader &reader)
switch (type) {
case QXmlStreamReader::Characters:
mImportProject = reader.text().toString();
FALLTHROUGH;
case QXmlStreamReader::EndElement:
return;
// Not handled
@ -298,6 +300,7 @@ bool ProjectFile::readBool(QXmlStreamReader &reader)
switch (type) {
case QXmlStreamReader::Characters:
ret = (reader.text().toString() == "true");
FALLTHROUGH;
case QXmlStreamReader::EndElement:
return ret;
// Not handled
@ -323,6 +326,7 @@ int ProjectFile::readInt(QXmlStreamReader &reader, int defaultValue)
switch (type) {
case QXmlStreamReader::Characters:
ret = reader.text().toString().toInt();
FALLTHROUGH;
case QXmlStreamReader::EndElement:
return ret;
// Not handled
@ -617,6 +621,7 @@ void ProjectFile::readPlatform(QXmlStreamReader &reader)
switch (type) {
case QXmlStreamReader::Characters:
mPlatform = reader.text().toString();
FALLTHROUGH;
case QXmlStreamReader::EndElement:
return;
// Not handled

View File

@ -121,7 +121,7 @@ struct Analyzer {
/// If the analysis is unsure whether to update a scope, this will return true if the analysis should bifurcate the scope
virtual bool updateScope(const Token* endBlock, bool modified) const = 0;
/// Called when a scope will be forked
virtual void forkScope(const Token* endBlock) {}
virtual void forkScope(const Token* /*endBlock*/) {}
/// If the value is conditional
virtual bool isConditional() const = 0;
/// The condition that will be assumed during analysis

View File

@ -929,7 +929,7 @@ void CheckIO::checkFormatString(const Token * const tok,
case 'l':
if (i+1 != formatString.end() && *(i+1) == *i)
specifier += *i++;
// fallthrough
FALLTHROUGH;
case 'j':
case 'q':
case 't':
@ -1255,7 +1255,7 @@ void CheckIO::checkFormatString(const Token * const tok,
specifier += *i++;
specifier += *i++;
}
// fallthrough
FALLTHROUGH;
case 'j': // intmax_t or uintmax_t
case 'z': // size_t
case 't': // ptrdiff_t

View File

@ -1105,7 +1105,7 @@ void CheckStl::invalidContainerLoopError(const Token *tok, const Token * loopTok
reportError(errorPath, Severity::error, "invalidContainerLoop", msg, CWE664, false);
}
void CheckStl::invalidContainerError(const Token *tok, const Token * contTok, const ValueFlow::Value *val, ErrorPath errorPath)
void CheckStl::invalidContainerError(const Token *tok, const Token * /*contTok*/, const ValueFlow::Value *val, ErrorPath errorPath)
{
const bool inconclusive = val ? val->isInconclusive() : false;
if (val)

View File

@ -46,6 +46,15 @@
# define NORETURN
#endif
// fallthrough
#if defined(__clang__)
# define FALLTHROUGH [[clang::fallthrough]]
#elif (defined(__GNUC__) && (__GNUC__ >= 7))
# define FALLTHROUGH __attribute__((fallthrough))
#else
# define FALLTHROUGH
#endif
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
#include <string>