Fix most clang -Wextra-semi-stmt warnings in C++ files

Suppress one in code generated by flex.
This commit is contained in:
Sean McBride 2019-01-11 16:58:56 -05:00 committed by Brad King
parent da566d4de8
commit b056bc3425
27 changed files with 81 additions and 66 deletions

View File

@ -52,6 +52,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION
"(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)" "(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
"(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)" "(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)"
"(Lexer|Parser).*warning.*variable.*was set but never used" "(Lexer|Parser).*warning.*variable.*was set but never used"
"LexerParser.*warning.*empty expression statement has no effect; remove unnecessary"
"PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c" "PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c"
"[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value" "[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value"
"warning:.*is.*very unsafe.*consider using.*" "warning:.*is.*very unsafe.*consider using.*"

View File

@ -112,13 +112,15 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(
return 0; \ return 0; \
} \ } \
cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \ cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \
if (!(archive)) { \ do { \
cmCPackLogger(cmCPackLog::LOG_ERROR, \ if (!(archive)) { \
"Problem to create archive <" \ cmCPackLogger(cmCPackLog::LOG_ERROR, \
<< (filename) << ">, ERROR = " << (archive).GetError() \ "Problem to create archive <" \
<< std::endl); \ << (filename) << ">, ERROR = " << (archive).GetError() \
return 0; \ << std::endl); \
} return 0; \
} \
} while (false)
int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
{ {

View File

@ -357,14 +357,18 @@ int cmCTestBuildHandler::ProcessHandler()
// Pre-compile regular expressions objects for all regular expressions // Pre-compile regular expressions objects for all regular expressions
#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \ #define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
regexes.clear(); \ do { \
cmCTestOptionalLog(this->CTest, DEBUG, \ regexes.clear(); \
this << "Add " #regexes << std::endl, this->Quiet); \
for (std::string const& s : (strings)) { \
cmCTestOptionalLog(this->CTest, DEBUG, \ cmCTestOptionalLog(this->CTest, DEBUG, \
"Add " #strings ": " << s << std::endl, this->Quiet); \ this << "Add " #regexes << std::endl, this->Quiet); \
(regexes).push_back(s.c_str()); \ for (std::string const& s : (strings)) { \
} cmCTestOptionalLog(this->CTest, DEBUG, \
"Add " #strings ": " << s << std::endl, \
this->Quiet); \
(regexes).push_back(s.c_str()); \
} \
} while (false)
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches, cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorMatches,
this->ErrorMatchRegex); this->ErrorMatchRegex);
cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions, cmCTestBuildHandlerPopulateRegexVector(this->CustomErrorExceptions,

View File

@ -57,7 +57,6 @@ public:
{ {
this->CommandLineStrings.clear(); this->CommandLineStrings.clear();
this->CommandLineStrings.push_back(command); this->CommandLineStrings.push_back(command);
;
} }
void AddArgument(const char* arg) void AddArgument(const char* arg)
{ {

View File

@ -671,7 +671,7 @@ Modify cmCommandArgumentLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h" #include "cmCommandArgumentParserTokens.h"

View File

@ -25,7 +25,7 @@ Modify cmCommandArgumentLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmCommandArgumentParserTokens.h" #include "cmCommandArgumentParserTokens.h"

View File

@ -869,7 +869,7 @@ Modify cmDependsJavaLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h" #include "cmDependsJavaParserTokens.h"

View File

@ -27,7 +27,7 @@ Modify cmDependsJavaLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmDependsJavaParserTokens.h" #include "cmDependsJavaParserTokens.h"

View File

@ -107,7 +107,7 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
#define YYMAXDEPTH 1000000 #define YYMAXDEPTH 1000000
#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp); #define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp)
#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval) #define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval)
#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) #define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */ /* Disable some warnings in the generated code. */

View File

@ -36,7 +36,7 @@ static void cmDependsJava_yyerror(yyscan_t yyscanner, const char* message);
#define YYMAXDEPTH 1000000 #define YYMAXDEPTH 1000000
#define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp); #define jpCheckEmpty(cnt) yyGetParser->CheckEmpty(__LINE__, cnt, yyvsp)
#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval) #define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval)
#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str)) #define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */ /* Disable some warnings in the generated code. */

View File

@ -671,7 +671,7 @@ Modify cmExprLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h" #include "cmExprParserTokens.h"

View File

@ -25,7 +25,7 @@ Modify cmExprLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = yyextra->LexInput(buf, max_size); } do { result = yyextra->LexInput(buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmExprParserTokens.h" #include "cmExprParserTokens.h"

View File

@ -848,7 +848,7 @@ Modify cmFortranLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmFortranParser_Input(yyextra, buf, max_size); } do { result = cmFortranParser_Input(yyextra, buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmFortranParserTokens.h" #include "cmFortranParserTokens.h"

View File

@ -37,7 +37,7 @@ Modify cmFortranLexer.cxx:
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmFortranParser_Input(yyextra, buf, max_size); } do { result = cmFortranParser_Input(yyextra, buf, max_size); } while (0)
/* Include the set of tokens from the parser. */ /* Include the set of tokens from the parser. */
#include "cmFortranParserTokens.h" #include "cmFortranParserTokens.h"

View File

@ -805,7 +805,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -57,7 +57,7 @@ static void cmListFileLexerDestroy(cmListFileLexer* lexer);
/* Replace the lexer input function. */ /* Replace the lexer input function. */
#undef YY_INPUT #undef YY_INPUT
#define YY_INPUT(buf, result, max_size) \ #define YY_INPUT(buf, result, max_size) \
{ result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } do { result = cmListFileLexerInput(cmListFileLexer_yyget_extra(yyscanner), buf, max_size); } while (0)
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
%} %}

View File

@ -135,7 +135,7 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c,
return; return;
} }
break; break;
}; }
#if !defined(_WIN32) || defined(__CYGWIN__) #if !defined(_WIN32) || defined(__CYGWIN__)
if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) { if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) {
this->Error = "archive_read_disk_set_standard_lookup: "; this->Error = "archive_read_disk_set_standard_lookup: ";

View File

@ -2853,9 +2853,11 @@ static const char* cmCTestStringLogType[] = { "DEBUG",
nullptr }; nullptr };
#define cmCTestLogOutputFileLine(stream) \ #define cmCTestLogOutputFileLine(stream) \
if (this->ShowLineNumbers) { \ do { \
(stream) << std::endl << file << ":" << line << " "; \ if (this->ShowLineNumbers) { \
} (stream) << std::endl << file << ":" << line << " "; \
} \
} while (false)
void cmCTest::InitStreams() void cmCTest::InitStreams()
{ {

View File

@ -14,11 +14,13 @@
#endif #endif
#define check_curl_result(result, errstr) \ #define check_curl_result(result, errstr) \
if ((result) != CURLE_OK && (result) != CURLE_NOT_BUILT_IN) { \ do { \
e += e.empty() ? "" : "\n"; \ if ((result) != CURLE_OK && (result) != CURLE_NOT_BUILT_IN) { \
e += (errstr); \ e += e.empty() ? "" : "\n"; \
e += ::curl_easy_strerror(result); \ e += (errstr); \
} e += ::curl_easy_strerror(result); \
} \
} while (false)
std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile) std::string cmCurlSetCAInfo(::CURL* curl, const char* cafile)
{ {

View File

@ -139,10 +139,12 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
} }
#define GET_OPT_ARGUMENT(target) \ #define GET_OPT_ARGUMENT(target) \
if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \ do { \
(target) = argv[i + 1]; \ if ((i + 1 < argc) && !this->IsOption(argv[i + 1])) { \
i = i + 1; \ (target) = argv[i + 1]; \
}; i = i + 1; \
}; \
} while (false)
void cmDocumentation::WarnFormFromFilename( void cmDocumentation::WarnFormFromFilename(
cmDocumentation::RequestedHelpItem& request, bool& result) cmDocumentation::RequestedHelpItem& request, bool& result)

View File

@ -382,7 +382,6 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
xml.StartElement("natures"); xml.StartElement("natures");
xml.Element("nature", "org.eclipse.cdt.make.core.makeNature"); xml.Element("nature", "org.eclipse.cdt.make.core.makeNature");
xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature"); xml.Element("nature", "org.eclipse.cdt.make.core.ScannerConfigNature");
;
for (std::string const& n : this->Natures) { for (std::string const& n : this->Natures) {
xml.Element("nature", n); xml.Element("nature", n);

View File

@ -2699,12 +2699,14 @@ private:
#endif #endif
#define check_curl_result(result, errstr) \ #define check_curl_result(result, errstr) \
if (result != CURLE_OK) { \ do { \
std::string e(errstr); \ if (result != CURLE_OK) { \
e += ::curl_easy_strerror(result); \ std::string e(errstr); \
this->SetError(e); \ e += ::curl_easy_strerror(result); \
return false; \ this->SetError(e); \
} return false; \
} \
} while (false)
bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args) bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{ {

View File

@ -435,14 +435,14 @@ static void handleSystemIncludesDep(
/* clang-format off */ /* clang-format off */
#define IMPLEMENT_VISIT(KIND) \ #define IMPLEMENT_VISIT(KIND) \
{ \ do { \
KindedSources const& kinded = this->GetKindedSources(config); \ KindedSources const& kinded = this->GetKindedSources(config); \
for (SourceAndKind const& s : kinded.Sources) { \ for (SourceAndKind const& s : kinded.Sources) { \
if (s.Kind == KIND) { \ if (s.Kind == KIND) { \
data.push_back(s.Source.Value); \ data.push_back(s.Source.Value); \
} \ } \
} \ } \
} } while (false)
/* clang-format on */ /* clang-format on */
void cmGeneratorTarget::GetObjectSources( void cmGeneratorTarget::GetObjectSources(

View File

@ -198,12 +198,12 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
std::cout << "Reading GraphViz options file: " << inFileName << std::endl; std::cout << "Reading GraphViz options file: " << inFileName << std::endl;
#define __set_if_set(var, cmakeDefinition) \ #define __set_if_set(var, cmakeDefinition) \
{ \ do { \
const char* value = mf.GetDefinition(cmakeDefinition); \ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \ if (value) { \
(var) = value; \ (var) = value; \
} \ } \
} } while (false)
__set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE"); __set_if_set(this->GraphType, "GRAPHVIZ_GRAPH_TYPE");
__set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME"); __set_if_set(this->GraphName, "GRAPHVIZ_GRAPH_NAME");
@ -211,12 +211,12 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
__set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX"); __set_if_set(this->GraphNodePrefix, "GRAPHVIZ_NODE_PREFIX");
#define __set_bool_if_set(var, cmakeDefinition) \ #define __set_bool_if_set(var, cmakeDefinition) \
{ \ do { \
const char* value = mf.GetDefinition(cmakeDefinition); \ const char* value = mf.GetDefinition(cmakeDefinition); \
if (value) { \ if (value) { \
(var) = mf.IsOn(cmakeDefinition); \ (var) = mf.IsOn(cmakeDefinition); \
} \ } \
} } while (false)
__set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES"); __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES");
__set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS"); __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS");

View File

@ -1021,7 +1021,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::string config; std::string config;
if (args.size() > 3) { if (args.size() > 3) {
config = args[3]; config = args[3];
}; }
return autoGen.Run(infoFile, config) ? 0 : 1; return autoGen.Run(infoFile, config) ? 0 : 1;
} }
#endif #endif
@ -1485,7 +1485,7 @@ int cmcmd::ExecuteLinkScript(std::vector<std::string>& args)
break; break;
default: default:
break; break;
}; }
} }
// Free the process instance. // Free the process instance.

View File

@ -16,10 +16,12 @@
#include <utility> #include <utility>
#define ASSERT_TRUE(x) \ #define ASSERT_TRUE(x) \
if (!(x)) { \ do { \
std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \ if (!(x)) { \
return false; \ std::cout << "ASSERT_TRUE(" #x ") failed on line " << __LINE__ << "\n"; \
} return false; \
} \
} while (false)
static bool testConstructDefault() static bool testConstructDefault()
{ {
@ -144,7 +146,6 @@ static bool testConstructFromCStr()
{ {
std::cout << "testConstructFromCStr()\n"; std::cout << "testConstructFromCStr()\n";
return testFromCStr(cstr); return testFromCStr(cstr);
;
} }
static bool testAssignFromCStr() static bool testAssignFromCStr()
@ -153,7 +154,6 @@ static bool testAssignFromCStr()
cm::String str; cm::String str;
str = cstr; str = cstr;
return testFromCStr(str); return testFromCStr(str);
;
} }
static const std::string stdstr = "abc"; static const std::string stdstr = "abc";

View File

@ -16,11 +16,13 @@
failed = 1 failed = 1
#define cmAssert(exp, m) \ #define cmAssert(exp, m) \
if ((exp)) { \ do { \
cmPassed(m); \ if ((exp)) { \
} else { \ cmPassed(m); \
cmFailed(m); \ } else { \
} cmFailed(m); \
} \
} while (false)
int testSystemTools(int /*unused*/, char* /*unused*/ []) int testSystemTools(int /*unused*/, char* /*unused*/ [])
{ {