Skip to content

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

@autoantwort

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.

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

1 participant