From 7ff6d691e27fd8fec8b3ed9526109b4ce70ea8b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Oct 2020 18:18:30 +0200 Subject: [PATCH] Manual: Clarify section about inline suppressions. For backwards compatibility we might need to handle a comment after a '{' differently. --- man/manual.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/man/manual.md b/man/manual.md index 1323a011d..e70b6b182 100644 --- a/man/manual.md +++ b/man/manual.md @@ -473,6 +473,20 @@ Or at the same line as the code: arr[10] = 0; // cppcheck-suppress arrayIndexOutOfBounds } +In this example there are 2 lines with code and 1 suppression comment. The suppression comment only applies to 1 line: `a = b + c;`. + + void f() { + a = b + c; // cppcheck-suppress abc + d = e + f; + } + +As a special case for backwards compatibility, if you have a `{` on its own line and a suppression comment after that, then that will suppress warnings for both the current and next line. This example will suppress `abc` warnings both for `{` and for `a = b + c;`: + + void f() + { // cppcheck-suppress abc + a = b + c; + } + ### Multiple suppressions For a line of code there might be several warnings you want to suppress.