From 3a76f2df0135f07f22806962aedd3fe926876e51 Mon Sep 17 00:00:00 2001 From: chrchr-github Date: Sun, 6 Sep 2026 22:51:14 +0200 Subject: [PATCH] Fix #15014 FP syntaxError (negating dereferenced pointer) --- lib/tokenize.cpp | 2 +- test/testtokenize.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 7a0a2e4f5c9..49a29f83848 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3768,7 +3768,7 @@ void Tokenizer::concatenateNegativeNumberAndAnyPositive() if (tok->findOpeningBracket()) continue; - if (!tok->tokAt(2) || (tok->tokAt(2)->isOp() && !Token::Match(tok->tokAt(2), "[+-]"))) + if (!tok->tokAt(2) || (tok->tokAt(2)->isOp() && !Token::Match(tok->tokAt(2), "[+-*]"))) syntaxError(tok); while (tok->str() != ">" && tok->next() && tok->strAt(1) == "+" && (!Token::Match(tok->tokAt(2), "%name% (|;") || Token::Match(tok, "%op%"))) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 8fd143e2fdd..76e8b922f5b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8080,6 +8080,10 @@ class TestTokenizer : public TestFixture { " for (int i : [](int a, int b) { ++a; ++b; return std::vector{a, b}; }(1, 2)) {}\n" "}\n")); + ASSERT_NO_THROW(tokenizeAndStringify("void f(int* p) {\n" // #15014 + " *p = -*p;\n" + "}\n")); + ignore_errout(); ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809