FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix #11538: Fix syntax error on C++23 'if consteval' / 'if !consteval' by autoantwort · Pull Request #8733 · cppcheck-opensource/cppcheck · GitHub

Fix #11538: Fix syntax error on C++23 'if consteval' / 'if !consteval' - #8733

Open
autoantwort wants to merge 1 commit into
cppcheck-opensource:mainfrom
autoantwort:feature/fix-if-consteval
Open

Fix #11538: Fix syntax error on C++23 'if consteval' / 'if !consteval'#8733
autoantwort wants to merge 1 commit into
cppcheck-opensource:mainfrom
autoantwort:feature/fix-if-consteval

Conversation

Copy link
Copy Markdown
Contributor

The tokenizer only recognized if constexpr (...) and treated any other if <name> without parentheses as a syntax error, so C++23's if consteval { ... } and if !consteval { ... } were rejected.

Rewrite them to if ( __cppcheck_consteval__ ) { ... } and if ( ! __cppcheck_consteval__ ) { ... } respectively, using a synthetic unresolved symbol rather than a boolean literal so that valueflow can't treat the condition as always true/false.

danmar 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Your suggested transformation seems valid to me. Feel free to finish this approach..

Comment thread lib/tokenize.cpp
The tokenizer only recognized 'if constexpr (...)' and treated any
other 'if <name>' without parentheses as a syntax error, so C++23's
'if consteval { ... }' and 'if !consteval { ... }' were rejected.

Rewrite them to 'if ( __cppcheck_consteval__ ) { ... }' and
'if ( ! __cppcheck_consteval__ ) { ... }' respectively, using a
synthetic unresolved symbol rather than a boolean literal so that
valueflow can't treat the condition as always true/false.
autoantwort force-pushed the feature/fix-if-consteval branch from 2ebe4cc to e5b16e1 Compare August 10, 2026 16:37

danmar 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

you insert parentheses but the links are not set. Is that done later?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL