Skip to content

Fix #14972 [regression] Syntax Error: AST broken, '!' doesn't have an operand. - #8791

Open
chrchr-github wants to merge 1 commit into
cppcheck-opensource:mainfrom
chrchr-github:chr_14972
Open

Fix #14972 [regression] Syntax Error: AST broken, '!' doesn't have an operand.#8791
chrchr-github wants to merge 1 commit into
cppcheck-opensource:mainfrom
chrchr-github:chr_14972

Conversation

@chrchr-github

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread lib/tokenize.cpp
Token *tok = matchMemberName(var, scopeInfo);
if (Token::Match(tok, "%name%")) {
if (!tok->next() || tok->strAt(1) != "(" || (tok->tokAt(2) && tok->tokAt(2)->isLiteral()))
if (!tok->next() || tok->strAt(1) != "(" || (tok->tokAt(2) && (tok->tokAt(2)->isLiteral() || tok->tokAt(2)->isOp())))

@danmar danmar Aug 22, 2026

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.

this looks fragile. Can you make sure it works with more than 1 parenthesis. I.e.:

struct Test {
    static bool constant;
};

bool Test::constant((!false));

I recommend a while loop that skips ( tokens.

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