Skip to content

Fix #14894: false positive: co_return not recognized as return in combination with {} #8741

Open
ludviggunne wants to merge 2 commits into
cppcheck-opensource:mainfrom
ludviggunne:14894-co_return-braces
Open

Fix #14894: false positive: co_return not recognized as return in combination with {} #8741
ludviggunne wants to merge 2 commits into
cppcheck-opensource:mainfrom
ludviggunne:14894-co_return-braces

Conversation

@ludviggunne

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/forwardanalyzer.cpp
if (out)
*out = loopEnds.back();
} else if (Token::Match(tok, "return|throw")) {
} else if (Token::Match(tok, "return|co_return|throw")) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will probably crop up in multiple places, so we might want to add a helper function, which should also check language and standard.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure where I would put it. A method of Token maybe?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Or put it in our dumping ground, astutils.cpp. E.g. isUnevaluated() also lives there.

@ludviggunne
ludviggunne force-pushed the 14894-co_return-braces branch from 7a50aff to 09d75c1 Compare July 21, 2026 13:27
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