我發現--suppress=unmatchedSuppression
只能抑制cppcheck選項中不匹配的抑制類型,但不能抑制不匹配的內聯抑制。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: arrayIndexOutOfBounds
在警告(以及其他不相關的警告)test.c
line 7
(預期)unmatchedSuppression: cstyleCast
在*
line 0
(預期)
情況2
同情況1,但額外--suppress=unmatchedSuppression
選項
cppcheck --inline-suppr --force --enable=all
--xml-version=2 --suppress=cstyleCast --suppress=unmatchedSuppressiontest.c
2>cppcheckresults.xml
我想到以前都警告unmatchedSuppression
走開。但我仍然得到
unmatchedSuppression
在test.c
line 7
(預計不會)