Skip to content

Fix syntaxError on lambda inside decltype#4650

Merged
danmar merged 1 commit intocppcheck-opensource:mainfrom
gerboengels:fix_syntaxerror_on_lambda_inside_using
Dec 18, 2022
Merged

Fix syntaxError on lambda inside decltype#4650
danmar merged 1 commit intocppcheck-opensource:mainfrom
gerboengels:fix_syntaxerror_on_lambda_inside_using

Conversation

@gerboengels
Copy link
Copy Markdown
Contributor

Got a syntax error on the following use case:

void f() {
  using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); });
  std::map<X, int, customComparator> m;
}

The issue being that the semicolon inside the lambda was matched as the end of the using-statement, instead of the semicolon at the end of the line

This PR fixes this case

Use case where it gave an issue:

using customComparator = decltype([] (const X& lhs, const X& rhs) { return lhs.CompareTo(rhs); });
std::map<X, int, costomComparator> m;
@danmar danmar merged commit 63e30d1 into cppcheck-opensource:main Dec 18, 2022
@gerboengels gerboengels deleted the fix_syntaxerror_on_lambda_inside_using branch January 7, 2023 21:19
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.

3 participants