-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix #13378: syntax error for guessed macro value #7218
base: main
Are you sure you want to change the base?
Conversation
You can specify actual macros via the CLI (at least with compilers): I used this recently somewhere in simplecpp or Cppcheck (most likely a local change) but I cannot remember where. |
Hm, sorry but could you point out how this affects this PR? |
And I guess having This might also be addressed by fixing a On a side note - if we would apply that logic during the macro parsing we could (optionally) generate a configuration which already provides these - in some cases. That would require less user interaction. But that is obviously out of scope. |
Ah, maybe I should have provided more context.
|
My fault. I did not look at the ticket. But to be fair there are also no tests added. But I guess you will also get that message if the preprocessor check is missing. I will file tickets about my notes. |
Oh yes, just thought it would be good to have it up as a draft to get som input on the messages. |
I think it is a good change we can built upon. |
if (tok->strAt(1) == "(") | ||
if (tok->strAt(1) == "(") { | ||
if (tok->isExpandedMacro() && mSettings.userDefines.empty()) { | ||
throw InternalError(tok, "literal used as function. Macro '" + tok->getMacroName() + |
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.
my goal would be that this message is only written if the macro is defined by Preprocessor::getConfigs
=> that means the macro value is guessed by Cppcheck.
The configuration is passed to Tokenizer::simplifyTokens1
. Can that be propagated here so that we can check if it contains the macro name?
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.
It seems the configuration is overriden by CLI/project defines by then already:
Line 1100 in 599f505
mCurrentConfig = mSettings.userDefines; |
But that only happens if mSettings.userDefines
is empty, so I think it should be enough to check the same condition in findGarbageCode
.
That's a good point. I suppose it could make the message quite long, would it be appropriate to split it into multiple messages? |
I would keep it simple as it is not mention it at all. This is another case where the list of suggestions could be endless and misleading. |
Example output:
With
-DSTART
the syntax error remains: