Skip to content

Commit 51b4cf5

Browse files
Fix #11029 unknownMacro reported with noexcept (regression) (#4073)
1 parent e293b66 commit 51b4cf5

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

lib/tokenize.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10196,10 +10196,12 @@ void Tokenizer::reportUnknownMacros() const
1019610196
unknownMacroError(tok);
1019710197
}
1019810198
} else if (Token::Match(tok, "%name% (") && tok->isUpperCaseName() && Token::Match(tok->linkAt(1), ") %name% (") && Token::Match(tok->linkAt(1)->linkAt(2), ") [;{]")) {
10199-
if (possible.count(tok->str()) == 0)
10200-
possible.insert(tok->str());
10201-
else
10202-
unknownMacroError(tok);
10199+
if (!(tok->linkAt(1)->next() && tok->linkAt(1)->next()->isKeyword())) { // e.g. noexcept(true)
10200+
if (possible.count(tok->str()) == 0)
10201+
possible.insert(tok->str());
10202+
else
10203+
unknownMacroError(tok);
10204+
}
1020310205
}
1020410206
}
1020510207

test/testtokenize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6551,6 +6551,9 @@ class TestTokenizer : public TestFixture {
65516551

65526552
const char code10[] = "void f(std::exception c) { b(M() M() + N(c.what())); }";
65536553
ASSERT_THROW(tokenizeAndStringify(code10), InternalError);
6554+
6555+
const char code11[] = "struct B { B(B&&) noexcept {} ~B() noexcept {} };";
6556+
ASSERT_NO_THROW(tokenizeAndStringify(code11));
65546557
}
65556558

65566559
void findGarbageCode() { // Test Tokenizer::findGarbageCode()

0 commit comments

Comments
 (0)