From 51b4cf592b400c86cef96737c275f329fa4329ac Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 3 May 2022 13:37:14 +0200 Subject: [PATCH] Fix #11029 unknownMacro reported with noexcept (regression) (#4073) --- lib/tokenize.cpp | 10 ++++++---- test/testtokenize.cpp | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 4a1455b70..4af721006 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -10196,10 +10196,12 @@ void Tokenizer::reportUnknownMacros() const unknownMacroError(tok); } } else if (Token::Match(tok, "%name% (") && tok->isUpperCaseName() && Token::Match(tok->linkAt(1), ") %name% (") && Token::Match(tok->linkAt(1)->linkAt(2), ") [;{]")) { - if (possible.count(tok->str()) == 0) - possible.insert(tok->str()); - else - unknownMacroError(tok); + if (!(tok->linkAt(1)->next() && tok->linkAt(1)->next()->isKeyword())) { // e.g. noexcept(true) + if (possible.count(tok->str()) == 0) + possible.insert(tok->str()); + else + unknownMacroError(tok); + } } } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 3c38140f5..d3c2e9c3a 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6551,6 +6551,9 @@ private: const char code10[] = "void f(std::exception c) { b(M() M() + N(c.what())); }"; ASSERT_THROW(tokenizeAndStringify(code10), InternalError); + + const char code11[] = "struct B { B(B&&) noexcept {} ~B() noexcept {} };"; + ASSERT_NO_THROW(tokenizeAndStringify(code11)); } void findGarbageCode() { // Test Tokenizer::findGarbageCode()