From c3de128a5f77b8cdb91d19444126e90d50725c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 4 Oct 2020 16:42:09 +0200 Subject: [PATCH] Testing backwards compatible inline suppression --- test/cli/proj-inline-suppress/3.cpp | 6 ++++++ test/cli/test-inline-suppress.py | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 test/cli/proj-inline-suppress/3.cpp diff --git a/test/cli/proj-inline-suppress/3.cpp b/test/cli/proj-inline-suppress/3.cpp new file mode 100644 index 000000000..7ecd1c0e8 --- /dev/null +++ b/test/cli/proj-inline-suppress/3.cpp @@ -0,0 +1,6 @@ +// From forum: https://sourceforge.net/p/cppcheck/discussion/general/thread/e67653efdb/ +void foo() +{ // cppcheck-suppress zerodiv + int x = 10000 / 0; +} + diff --git a/test/cli/test-inline-suppress.py b/test/cli/test-inline-suppress.py index 9b4102d2e..d570f27f5 100644 --- a/test/cli/test-inline-suppress.py +++ b/test/cli/test-inline-suppress.py @@ -24,3 +24,10 @@ def test_unmatched_suppression_path_with_extra_stuf(): ret, stdout, stderr = cppcheck(['--inline-suppr', '--enable=information', '--error-exitcode=1', './proj-inline-suppress/2.c']) assert ret == 1 assert 'Unmatched suppression: some_warning_id' in stderr + +def test_backwards_compatibility(): + ret, stdout, stderr = cppcheck(['proj-inline-suppress/3.cpp']) + assert '[zerodiv]' in stderr + + ret, stdout, stderr = cppcheck(['--inline-suppr', 'proj-inline-suppress/3.cpp']) + assert stderr == ''