diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 166662622a3..0db807333c0 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6363,7 +6363,7 @@ void Tokenizer::simplifyHeadersAndUnusedTemplates() } } - if (!tok->previous() || Token::Match(tok->previous(), "[;{}]")) { + if (!tok->previous() || Token::Match(tok->previous(), "[;{}:]")) { // Remove unused function declarations if (isIncluded && removeUnusedIncludedFunctions) { while (true) { diff --git a/test/cli/other_test.py b/test/cli/other_test.py index a747493e48d..fa96bbd64b3 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3164,6 +3164,15 @@ def test_check_unused_templates_func(tmp_path): # #13714 (void)(*((int*)0)); } +class S { +public: + template + void f_t_3() + { + (void)(*((int*)0)); + } +}; + void f() {} """)