Skip to content

Commit 73b2ad6

Browse files
Follow-up to #13712: Report unknownMacro (danmar#8152)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent e071e29 commit 73b2ad6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/tokenize.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8981,8 +8981,12 @@ void Tokenizer::findGarbageCode() const
89818981
syntaxError(tok->next());
89828982
if (Token::Match(tok, "%name% %op% %name%") && !tok->isKeyword() && tok->next()->isIncDecOp())
89838983
syntaxError(tok->next());
8984-
if (!tok->isKeyword() && Token::Match(tok, "%name% .|-> %name% %name%") && !tok->tokAt(2)->isKeyword())
8985-
syntaxError(tok);
8984+
if (!tok->isKeyword() && Token::Match(tok, "%name% .|-> %name% %name%") && !tok->tokAt(2)->isKeyword()) {
8985+
if (tok->tokAt(3)->isUpperCaseName())
8986+
unknownMacroError(tok->tokAt(3));
8987+
else
8988+
syntaxError(tok);
8989+
}
89868990
if (Token::Match(tok, "[!|+-/%^~] )|]"))
89878991
syntaxError(tok);
89888992
if (Token::Match(tok, "==|!=|<=|>= %comp%") && tok->strAt(-1) != "operator")

test/testtokenize.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7668,6 +7668,11 @@ class TestTokenizer : public TestFixture {
76687668
"}"),
76697669
SYNTAX);
76707670

7671+
ASSERT_THROW_INTERNAL(tokenizeAndStringify("void f(T* p) {\n"
7672+
" g(p->x TSRMLS_CC);"
7673+
"}"),
7674+
UNKNOWN_MACRO);
7675+
76717676
ASSERT_NO_THROW(tokenizeAndStringify("S* g = ::new(ptr) S();")); // #12552
76727677
ASSERT_NO_THROW(tokenizeAndStringify("void f(int* p) { return ::delete p; }"));
76737678

0 commit comments

Comments
 (0)