From 68eabb357616f7ef469b20dd8d9cb8ce588e113d Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 23 Jan 2019 13:17:22 -0500 Subject: Avoid -Wstring-plus-int warning In `cmState::GetGlobalProperty` we use a macro to produce a string of the form ";a;b;c" and want to return "a;b;c" by skipping the leading ";". Switch from pointer arithmetic to indexing+addressing to silence the "warning: adding 'int' to a string does not append to the string" diagnostic from Clang. --- Source/cmState.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index d4d3df5..fdd7b3d 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -545,10 +545,10 @@ const char* cmState::GetGlobalProperty(const std::string& prop) } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { - return FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_C_FEATURE(STRING_LIST_ELEMENT)[1]; } if (prop == "CMAKE_CXX_KNOWN_FEATURES") { - return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1; + return &FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT)[1]; } #undef STRING_LIST_ELEMENT return this->GlobalProperties.GetPropertyValue(prop); -- cgit v0.12 From c3203bf31637a960d1bf579fb7092a1ae850cdb5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 23 Jan 2019 13:20:14 -0500 Subject: Silence -Wcomma warning We use a comma-in-paren expression to evaluate multiple statements in a condition. Clang warns that this may be incorrect. Follow its suggestion to cast all but the last expression to `void` to silence the warning. --- Source/cmListFileCache.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index ff793f6..cc2c09f 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -193,8 +193,9 @@ bool cmListFileParser::ParseFunction(const char* name, long line) unsigned long lastLine; unsigned long parenDepth = 0; this->Separation = SeparationOkay; - while ((lastLine = cmListFileLexer_GetCurrentLine(this->Lexer), - token = cmListFileLexer_Scan(this->Lexer))) { + while ( + (static_cast(lastLine = cmListFileLexer_GetCurrentLine(this->Lexer)), + token = cmListFileLexer_Scan(this->Lexer))) { if (token->type == cmListFileLexer_Token_Space || token->type == cmListFileLexer_Token_Newline) { this->Separation = SeparationOkay; -- cgit v0.12