From 635bc69d87d36913ff61eceee9a4b84693c51853 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Thu, 1 Oct 2026 19:41:57 +0200 Subject: [PATCH] Fix #15079 Regression: FP syntaxError for C-style cast before `::` --- lib/tokenize.cpp | 4 ++-- test/testtokenize.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7f92d66eb78..790611cd4d4 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -9179,8 +9179,8 @@ void Tokenizer::findGarbageCode() const syntaxError(tok); if (Token::simpleMatch(tok->tokAt(-1), ")")) { const Token* const prev = tok->linkAt(-1)->tokAt(-1); - if (!Token::Match(prev, "%name% (") || (!prev->isControlFlowKeyword() && prev->str() != "decltype")) { - if (prev && prev->isUpperCaseName()) + if (prev && prev->isNameOnly()) { + if (prev->isUpperCaseName()) unknownMacroError(prev); else syntaxError(tok); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 88183c3db5b..8639a8844e5 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -7929,6 +7929,14 @@ class TestTokenizer : public TestFixture { " }\n" "}\n"), UNKNOWN_MACRO); + ASSERT_NO_THROW(tokenizeAndStringify("void f(void* h) {\n" // #15079 + " (void)::CloseHandle(h);\n" + " int i = (int)::GetTickCount();\n" + "}\n" + "std::size_t* g(void* p) {\n" + " return new (p) ::std::size_t;\n" + "}\n")); + ASSERT_THROW_INTERNAL_EQUALS(tokenizeAndStringify("static void handle_toggle(void (*proc) PROTO_XT_CALLBACK_ARGS, int var) {}\n"), // #13198 UNKNOWN_MACRO, "There is an unknown macro here somewhere. Configuration is required. If PROTO_XT_CALLBACK_ARGS is a macro then please configure it.");