-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #15XXX syntaxError for ternary with two inequalities #8913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -401,6 +401,7 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) | |
| return 0; | ||
|
|
||
| unsigned int level = 0; | ||
| unsigned int inTernary = 0; | ||
|
|
||
| while (tok) { | ||
| // skip template template | ||
|
|
@@ -460,8 +461,16 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) | |
| } | ||
|
|
||
| // Skip '=', '?', ':' | ||
| if (Token::Match(tok, "=|?|:")) | ||
| if (Token::Match(tok, "=|?|:")) { | ||
| if (tok->str()[0] == '?') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve button Since the surrounding code compares whole strings ( |
||
| ++inTernary; | ||
| else if (tok->str()[0] == ':') { | ||
| if (inTernary == 0) | ||
| return 0; | ||
| --inTernary; | ||
| } | ||
| tok = tok->next(); | ||
| } | ||
| if (!tok) | ||
| return 0; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an AI review take it with a grain of salt. Please feel free to reject it by clicking on Resolve button
Minor naming nit:
inTernaryreads like a bool, but it is a nesting counter. Something liketernaryLevelwould match the existinglevelvariable in this function and make--ternaryLevelread more naturally.