Skip to content

Commit 3a76f2d

Browse files
committed
Fix #15014 FP syntaxError (negating dereferenced pointer)
1 parent f9ca1b4 commit 3a76f2d

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3768,7 +3768,7 @@ void Tokenizer::concatenateNegativeNumberAndAnyPositive()
37683768
if (tok->findOpeningBracket())
37693769
continue;
37703770

3771-
if (!tok->tokAt(2) || (tok->tokAt(2)->isOp() && !Token::Match(tok->tokAt(2), "[+-]")))
3771+
if (!tok->tokAt(2) || (tok->tokAt(2)->isOp() && !Token::Match(tok->tokAt(2), "[+-*]")))
37723772
syntaxError(tok);
37733773

37743774
while (tok->str() != ">" && tok->next() && tok->strAt(1) == "+" && (!Token::Match(tok->tokAt(2), "%name% (|;") || Token::Match(tok, "%op%")))

test/testtokenize.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8080,6 +8080,10 @@ class TestTokenizer : public TestFixture {
80808080
" for (int i : [](int a, int b) { ++a; ++b; return std::vector<int>{a, b}; }(1, 2)) {}\n"
80818081
"}\n"));
80828082

8083+
ASSERT_NO_THROW(tokenizeAndStringify("void f(int* p) {\n" // #15014
8084+
" *p = -*p;\n"
8085+
"}\n"));
8086+
80838087
ignore_errout();
80848088

80858089
ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809

0 commit comments

Comments
 (0)