diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 436a6655284..06a8edf6e78 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3778,7 +3778,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->isArithmeticalOp() || tok->isComparisonOp()) && tok->str() != ">" && tok->next() && tok->strAt(1) == "+" && diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index d5c770169e4..63bf525dea6 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8195,6 +8195,17 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS(";", tokenizeAndStringify("typedef std::size_t size_t;\n")); // #14809 ASSERT_EQUALS("struct S { int i { 0 } ; } ;", tokenizeAndStringify("struct S { int i : 1{0}; };\n")); // #15070 + + ASSERT_EQUALS( // #15183 + "int f ( int i ) {\n" + "if ( i > 0 ) {\n" + "return - ! ! i ; }\n" + "return - ~ i ;\n" + "}", tokenizeAndStringify("int f(int i) {\n" + " if (i > 0)\n" + " return -!!i;\n" + " return -~i;\n" + "}\n")); }