Skip to content

Fix #15245 syntaxError on new[] with a braced initializer ending in a parenthesis - #9087

Open
tsobczynski wants to merge 1 commit into
cppcheck-opensource:mainfrom
tsobczynski:fix-15245-knr-tokend
Open

tsobczynski wants to merge 1 commit into
cppcheck-opensource:mainfrom
tsobczynski:fix-15245-knr-tokend

Conversation

@tsobczynski

Copy link
Copy Markdown

In Tokenizer::simplifyVarDecl, the K&R parameter pass no longer steps onto tokEnd when it skips a parenthesised group, which made the loop run past the end of its range. Test: vardecl38.

🤖 Generated with Claude Code

… parenthesis

In the K&R parameter pass, simplifyVarDecl skips a parenthesised group
and steps past its `)`. When that `)` is the last token before tokEnd,
the step lands on tokEnd and the loop increment then steps past it, so
the loop runs to the end of the token list and raises a syntax error.
findLambdaEndScope takes `[2]{(1)}` in `new int[2]{(1)}` for a lambda,
which produces such a range.

Don't step onto tokEnd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant