Skip to content

Commit

Permalink
unknownMacro
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Mar 27, 2024
1 parent df12d00 commit 915bf0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8652,8 +8652,12 @@ void Tokenizer::findGarbageCode() const
for (const Token* inner = tok->next(); inner != end; inner = inner->next()) {
if (inner->str() == "{")
inner = inner->link();
else if (inner->str() == ";")
syntaxError(inner);
else if (inner->str() == ";") {
if (tok->tokAt(-1) && tok->tokAt(-1)->isUpperCaseName())
unknownMacroError(tok->tokAt(-1))
else
syntaxError(inner);
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7074,8 +7074,9 @@ class TestTokenizer : public TestFixture {
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If U_ICU_ENTRY_POINT_RENAME is a macro then please configure it.");

ASSERT_THROW(tokenizeAndStringify("void f() { MACRO(x(), y(), \"abc\", z(); ok = true); }\n"), // #12006
InternalError);
ASSERT_THROW_EQUALS(tokenizeAndStringify("void f() { MACRO(x(), y(), \"abc\", z(); ok = true); }\n"), // #12006
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If MACRO is a macro then please configure it.");

ASSERT_THROW_EQUALS(tokenizeAndStringify("int (*f) MACRO((void *));\n"), // #12010
InternalError,
Expand Down Expand Up @@ -7588,7 +7589,9 @@ class TestTokenizer : public TestFixture {
}

void checkConfiguration() {
ASSERT_THROW(checkConfig("void f() { DEBUG(x();y()); }"), InternalError);
ASSERT_THROW_EQUALS(checkConfig("void f() { DEBUG(x();y()); }"),
InternalError,
"There is an unknown macro here somewhere. Configuration is required. If DEBUG is a macro then please configure it.");
}

void unknownType() { // #8952
Expand Down

0 comments on commit 915bf0f

Please sign in to comment.