Skip to content

Fix #15192 syntaxError on a pack expansion of decltype in a qualified template default argument followed by >> - #9010

Open
chrchr-github wants to merge 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15192
Open

chrchr-github wants to merge 2 commits into
cppcheck-opensource:mainfrom
chrchr-github:chr_15192

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review

I found no problems. The change is a one-token change in TemplateSimplifier::templateParameters: a ... may now follow ). That fixes the syntax error from #15192, and it also fixes related forms that failed on base, such as sizeof(Ts)..., (expr)... and the expansion followed by , int>>. Malformed inputs I tried still give the same result as on base, and nothing crashed or hung. The new test is in the right place, splitTemplateRightAngleBrackets.

Testing

I built cppcheck and testrunner in pr/ and cppcheck in base/. Both builds succeeded.

Test suites: ./testrunner for TestTokenizer, TestGarbage, TestSimplifyTemplate, TestSymbolDatabase and TestVarID. All passed with 0 failures.

Scratch files, run with cppcheck -q --enable=all --check-level=exhaustive on base and on the PR:

  • N::S<decltype(Ts())...>> (the ticket's case): base gives syntaxError; the PR parses it.
  • The unqualified S<decltype(Ts())...>>: no error on either build.
  • N::S<decltype(Ts())..., int>>: base gives syntaxError; the PR parses it.
  • N::S<int, decltype(Ts())...>>: parses on the PR.
  • N::S<sizeof(Ts)...>>: base gives syntaxError; the PR parses it.
  • N::S<(sizeof(Ts) > 1)...>>: base gives syntaxError; the PR parses it.
  • N::S<(Is + ...)>>: parses on the PR.
  • Nested N::W<N::S<decltype(Ts())...>>> and a using alias inside a class template: no error on either build.
  • An instantiation f<int, char>() followed by an uninitialized variable: base stops at the syntax error. The PR goes on and reports uninitvar as expected, so checking continues after the template.
  • Garbage inputs: A<(x)... ...>>, A<)...>> and X<(a)...>> b; give the same output on base and the PR, with no crash or hang.

Automated review of 33b4b3d by Claude. The pull request was built and tested locally.

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.

2 participants