Skip to content

Commit 1af959a

Browse files
authored
fixed -Wextra-semi-stmt Clang warnings (cppcheck-opensource#2553)
* fixed -Wextra-semi-stmt Clang warnings * adjusted REDIRECT macro to require a semicolon * testmathlib.cpp: rolled back accidental change
1 parent c606526 commit 1af959a

32 files changed

Lines changed: 179 additions & 144 deletions

cmake/compileroptions.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
6969
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-multichar")
7070
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-sign-compare")
7171
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-unused-function")
72+
# TODO: enable this warning - was added in Clang 8
73+
#set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wextra-semi-stmt")
7274

7375
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
7476
MESSAGE(FATAL_ERROR "Not use clang for generate code coverage. Use gcc. ")

externals/tinyxml/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ file(GLOB hdrs "*.h")
22
file(GLOB srcs "*.cpp")
33

44
add_library(tinyxml_objs OBJECT ${srcs} ${hdrs})
5+
# TODO: needs to be fixed upstream
56
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
6-
# TODO: needs to be fixed upstream
77
target_compile_options(tinyxml_objs PRIVATE -Wno-suggest-attribute=format)
8+
# TODO: enable this - was added in Clang 8
9+
#target_compile_options(tinyxml_objs PRIVATE -Wno-extra-semi-stmt)
810
endif()
911
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1012
add_library(tinyxml_objs_sanitized OBJECT EXCLUDE_FROM_ALL ${srcs} ${hdrs})
1113
target_compile_options(tinyxml_objs_sanitized PRIVATE -fsanitize=address)
14+
# TODO: enable this - was added in Clang 8
15+
#target_compile_options(tinyxml_objs_sanitized PRIVATE -Wno-extra-semi-stmt)
1216
endif()

gui/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ if (BUILD_GUI)
2929
target_compile_definitions (cppcheck-gui PRIVATE HAVE_QCHART )
3030
target_link_libraries(cppcheck-gui Qt5::Charts)
3131
endif()
32+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
33+
# TODO: enable this - was added in Clang 8
34+
# Q_UNUSED() in generated code
35+
#target_compile_options(cppcheck-gui PRIVATE -Wno-extra-semi-stmt)
36+
endif()
3237

3338
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)
3439
install(FILES ${qms} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)

lib/checkbufferoverrun.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static bool checkBufferSize(const Token *ftok, const Library::ArgumentChecks::Mi
565565
return minsize.value <= bufferSize;
566566
case Library::ArgumentChecks::MinSize::Type::NONE:
567567
break;
568-
};
568+
}
569569
return true;
570570
}
571571

lib/checkcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ static inline T getvalue(const int test, const T value1, const T value2)
945945
return value2;
946946
case 5:
947947
return std::numeric_limits<T>::max();
948-
};
948+
}
949949
return 0;
950950
}
951951

lib/checkleakautovar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void VarInfo::print()
104104
default:
105105
status = "?";
106106
break;
107-
};
107+
}
108108

109109
std::cout << "status=" << status << " "
110110
<< "alloctype='" << it->second.type << "' "

lib/checkunusedfunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static bool isOperatorFunction(const std::string & funcName)
287287
};
288288

289289

290-
return std::find(additionalOperators.begin(), additionalOperators.end(), funcName.substr(operatorPrefix.length())) != additionalOperators.end();;
290+
return std::find(additionalOperators.begin(), additionalOperators.end(), funcName.substr(operatorPrefix.length())) != additionalOperators.end();
291291
}
292292

293293

lib/checkunusedvar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ void CheckUnusedVar::checkFunctionVariableUsage()
11601160
case ValueType::Type::LONGDOUBLE:
11611161
check = true;
11621162
break;
1163-
};
1163+
}
11641164
if (!check)
11651165
continue;
11661166
}
@@ -1220,7 +1220,7 @@ void CheckUnusedVar::checkFunctionVariableUsage()
12201220
break;
12211221
case Library::TypeCheck::suppress:
12221222
continue;
1223-
};
1223+
}
12241224
}
12251225
}
12261226

lib/ctu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ static bool findPath(const std::string &callId,
504504
if (unsafeValue < 0 || unsafeValue >= functionCall->callArgValue)
505505
break;
506506
continue;
507-
};
507+
}
508508
path[index] = functionCall;
509509
return true;
510510
}

lib/exprengine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ static int getIntBitsFromValueType(const ValueType *vt, const cppcheck::Platform
10251025
return platform.long_long_bit;
10261026
default:
10271027
return 0;
1028-
};
1028+
}
10291029
}
10301030

10311031
static ExprEngine::ValuePtr getValueRangeFromValueType(const std::string &name, const ValueType *vt, const cppcheck::Platform &platform)
@@ -2041,7 +2041,7 @@ void ExprEngine::runChecks(ErrorLogger *errorLogger, const Tokenizer *tokenizer,
20412041
err |= value.isEqual(dataBase, MathLib::toLongNumber(invalidArgValue.op2));
20422042
bad = "range " + invalidArgValue.op1 + "-" + invalidArgValue.op2;
20432043
break;
2044-
};
2044+
}
20452045

20462046
if (err) {
20472047
dataBase->addError(tok->linenr());

0 commit comments

Comments
 (0)