【发布时间】:2017-04-25 04:18:49
【问题描述】:
我发现--suppress=unmatchedSuppression 只抑制 cppcheck 选项中不匹配的抑制类型,而不是不匹配的内联抑制。
这是预期的行为吗?
test.c
第 4 行错误。应该警告
arrayIndexOutOfBounds第 7 行没问题。不应该被警告
arrayIndexOutOfBounds
两行我都有内联cppcheck-suppress。
1 void f() {
2 char arr[5];
3 // cppcheck-suppress arrayIndexOutOfBounds
4 arr[10] = 0;
5
6 // cppcheck-suppress arrayIndexOutOfBounds
7 const char ok[] = "this line is ok";
8 }
情况1
抑制cstyleCast,它在代码中不存在。
cppcheck --inline-suppr --force --enable=all
--xml-version=2 --suppress=cstyleCast test.c
2>cppcheckresults.xml
我收到警告(以及其他不相关的警告)
unmatchedSuppression: arrayIndexOutOfBoundsintest.cline 7(如预期)unmatchedSuppression: cstyleCastin*line 0(如预期)
情况2
与情况 1 相同,但有额外的 --suppress=unmatchedSuppression 选项
cppcheck --inline-suppr --force --enable=all
--xml-version=2 --suppress=cstyleCast --suppress=unmatchedSuppressiontest.c
2>cppcheckresults.xml
我希望之前的两个 unmatchedSuppression 警告都会消失。但我仍然得到
-
unmatchedSuppressionintest.cline 7(不期望)
【问题讨论】:
标签: c++ static-code-analysis cppcheck