2016-12-09 14 views
3

--suppress=unmatchedSuppression은 cppcheck 옵션에서 비교할 수없는 억제 유형 만 억제하지만 타의 추종을 불허하는 인라인 억제는 발견하지 못했습니다.cppcheck 어떻게 인라인 일치하지 억제?

예상 된 동작입니까?

TEST.C

  • 4 호선은 잘못된 것입니다. 경고해야합니다 arrayIndexOutOfBounds

  • 7 번 라인은 괜찮습니다. 내가 두 라인 인라인 cppcheck-suppress

arrayIndexOutOfBounds 경고해서는 안됩니다.

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 } 

코드에 존재하지 않는 상황 일

억제 cstyleCast.

cppcheck --inline-suppr --force --enable=all 
      --xml-version=2 --suppress=cstyleCast test.c 
      2>cppcheckresults.xml 

나는

  1. unmatchedSuppression: arrayIndexOutOfBounds에 (다른 관련이없는 경고들)에 대해 경고를받을 test.cline 7 (예상대로)

  2. 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 경고가 사라 기대와 상황. 하지만 난 여전히 얻을 수있는

  1. unmatchedSuppressiontest.cline 7 (예상 NOT)

답변

1

내가 최근에 발견하면 인라인 suppressions에서 unmatchedSuppression 경고가 일반적인 --suppress=unmatchedSuppression 억제하거나 그 경고 ID를 넣어 수 없다는 것입니다 --suppressions-list 파일에 있습니다. 파일 이름을 지정해야합니다. 예 : --suppress=unmatchedSuppression:test.c.