fixed/aligned some compiler warnings (#3065)
This commit is contained in:
parent
95d1b41a5b
commit
491f4874c5
|
@ -51,6 +51,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
add_compile_options_safe(-Wdocumentation)
|
add_compile_options_safe(-Wdocumentation)
|
||||||
add_compile_options_safe(-Wdocumentation-pedantic)
|
add_compile_options_safe(-Wdocumentation-pedantic)
|
||||||
add_compile_options_safe(-Wno-documentation-unknown-command)
|
add_compile_options_safe(-Wno-documentation-unknown-command)
|
||||||
|
add_compile_options_safe(-Wimplicit-fallthrough)
|
||||||
|
|
||||||
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
|
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
|
||||||
message(FATAL_ERROR "Do not use clang for generate code coverage. Use gcc.")
|
message(FATAL_ERROR "Do not use clang for generate code coverage. Use gcc.")
|
||||||
|
|
|
@ -248,6 +248,7 @@ void ProjectFile::readBuildDir(QXmlStreamReader &reader)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::Characters:
|
case QXmlStreamReader::Characters:
|
||||||
mBuildDir = reader.text().toString();
|
mBuildDir = reader.text().toString();
|
||||||
|
FALLTHROUGH;
|
||||||
case QXmlStreamReader::EndElement:
|
case QXmlStreamReader::EndElement:
|
||||||
return;
|
return;
|
||||||
// Not handled
|
// Not handled
|
||||||
|
@ -273,6 +274,7 @@ void ProjectFile::readImportProject(QXmlStreamReader &reader)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::Characters:
|
case QXmlStreamReader::Characters:
|
||||||
mImportProject = reader.text().toString();
|
mImportProject = reader.text().toString();
|
||||||
|
FALLTHROUGH;
|
||||||
case QXmlStreamReader::EndElement:
|
case QXmlStreamReader::EndElement:
|
||||||
return;
|
return;
|
||||||
// Not handled
|
// Not handled
|
||||||
|
@ -298,6 +300,7 @@ bool ProjectFile::readBool(QXmlStreamReader &reader)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::Characters:
|
case QXmlStreamReader::Characters:
|
||||||
ret = (reader.text().toString() == "true");
|
ret = (reader.text().toString() == "true");
|
||||||
|
FALLTHROUGH;
|
||||||
case QXmlStreamReader::EndElement:
|
case QXmlStreamReader::EndElement:
|
||||||
return ret;
|
return ret;
|
||||||
// Not handled
|
// Not handled
|
||||||
|
@ -323,6 +326,7 @@ int ProjectFile::readInt(QXmlStreamReader &reader, int defaultValue)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::Characters:
|
case QXmlStreamReader::Characters:
|
||||||
ret = reader.text().toString().toInt();
|
ret = reader.text().toString().toInt();
|
||||||
|
FALLTHROUGH;
|
||||||
case QXmlStreamReader::EndElement:
|
case QXmlStreamReader::EndElement:
|
||||||
return ret;
|
return ret;
|
||||||
// Not handled
|
// Not handled
|
||||||
|
@ -617,6 +621,7 @@ void ProjectFile::readPlatform(QXmlStreamReader &reader)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QXmlStreamReader::Characters:
|
case QXmlStreamReader::Characters:
|
||||||
mPlatform = reader.text().toString();
|
mPlatform = reader.text().toString();
|
||||||
|
FALLTHROUGH;
|
||||||
case QXmlStreamReader::EndElement:
|
case QXmlStreamReader::EndElement:
|
||||||
return;
|
return;
|
||||||
// Not handled
|
// Not handled
|
||||||
|
|
|
@ -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
|
/// 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;
|
virtual bool updateScope(const Token* endBlock, bool modified) const = 0;
|
||||||
/// Called when a scope will be forked
|
/// Called when a scope will be forked
|
||||||
virtual void forkScope(const Token* endBlock) {}
|
virtual void forkScope(const Token* /*endBlock*/) {}
|
||||||
/// If the value is conditional
|
/// If the value is conditional
|
||||||
virtual bool isConditional() const = 0;
|
virtual bool isConditional() const = 0;
|
||||||
/// The condition that will be assumed during analysis
|
/// The condition that will be assumed during analysis
|
||||||
|
|
|
@ -929,7 +929,7 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
case 'l':
|
case 'l':
|
||||||
if (i+1 != formatString.end() && *(i+1) == *i)
|
if (i+1 != formatString.end() && *(i+1) == *i)
|
||||||
specifier += *i++;
|
specifier += *i++;
|
||||||
// fallthrough
|
FALLTHROUGH;
|
||||||
case 'j':
|
case 'j':
|
||||||
case 'q':
|
case 'q':
|
||||||
case 't':
|
case 't':
|
||||||
|
@ -1255,7 +1255,7 @@ void CheckIO::checkFormatString(const Token * const tok,
|
||||||
specifier += *i++;
|
specifier += *i++;
|
||||||
specifier += *i++;
|
specifier += *i++;
|
||||||
}
|
}
|
||||||
// fallthrough
|
FALLTHROUGH;
|
||||||
case 'j': // intmax_t or uintmax_t
|
case 'j': // intmax_t or uintmax_t
|
||||||
case 'z': // size_t
|
case 'z': // size_t
|
||||||
case 't': // ptrdiff_t
|
case 't': // ptrdiff_t
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ void CheckStl::invalidContainerLoopError(const Token *tok, const Token * loopTok
|
||||||
reportError(errorPath, Severity::error, "invalidContainerLoop", msg, CWE664, false);
|
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;
|
const bool inconclusive = val ? val->isInconclusive() : false;
|
||||||
if (val)
|
if (val)
|
||||||
|
|
|
@ -46,6 +46,15 @@
|
||||||
# define NORETURN
|
# define NORETURN
|
||||||
#endif
|
#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
|
#define REQUIRES(msg, ...) class=typename std::enable_if<__VA_ARGS__::value>::type
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
Loading…
Reference in New Issue