Repository navigation
Fix #15244, #15245 syntaxError and unsimplified function bodies in simplifyVarDecl - #9052
Open
tsobczynski wants to merge 2 commits into
Open
tsobczynski wants to merge 2 commits into
tsobczynski wants to merge 2 commits into
Conversation
…r precedes a trailing return type
isTrailingReturnType accepted only `) . type`, so a function or lambda
with a cv or ref qualifier, noexcept, noexcept(...), throw(...),
mutable, constexpr, consteval or static before `->` had its body taken
for a braced initializer, and simplifyVarDecl did not simplify it.
Inside such a body, findLambdaEndScope then accepted a structured
binding like `[p, c]{f()}` as a lambda.
Step back over those specifiers and return the parameter list's `)`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes in
Tokenizer::simplifyVarDecl, one commit each.isTrailingReturnTypenow steps back over the specifiers that can stand between the parameter list and->(cv and ref qualifiers,noexcept,noexcept(...),throw(...),mutable,constexpr,consteval,static). Before, a function or lambda with one of them had its body treated as a braced initializer, so the body was not simplified. Test:vardecl37.tokEndwhen it skips a parenthesised group, which made the loop run past the end of its range. Test:vardecl38.Both tests fail without the fixes.
testrunnerpasses in full.selfcheck.sh, built withENABLE_CHECK_INTERNALandUSE_MATCHCOMPILER=Verify, reports no new findings.🤖 Generated with Claude Code