Fix #14317 Syntax error using macro inside ifdef block#8123
Fix #14317 Syntax error using macro inside ifdef block#8123danmar merged 4 commits intodanmar:mainfrom
Conversation
|
I would expect that we test this in some way. |
|
This needs to be fixed in simplecpp, probably here: |
I am not sure. Then what happens if user executes cppcheck like this:
|
05b5536 to
eb9075c
Compare
|
hmm.. the fix seems to work when I test it quickly. but is in wrong repo. |
eb9075c to
8321b48
Compare
The solution did not work, so I'm working on a new solution. |
2ec411a to
52f76ef
Compare
| "#error abcd\n" | ||
| "#endif\n"; | ||
| ASSERT_EQUALS("\nA\n", getConfigsStr(filedata)); | ||
| ASSERT_EQUALS("\nA=A\n", getConfigsStr(filedata)); |
There was a problem hiding this comment.
This raises the question, do we want to print A=A when it was just A before? @danmar
There was a problem hiding this comment.
Yes that is a question. I think it's good to explicitly show that A=A expansion is used. And the "=1" is not wrong to show but it's redundant.
When configuring the defines in the GUI project file dialog, "A;B" means that A and B will be 1. While "A=A;B" would mean that A macro will get value "A" and B macro would get value "1". As far as I know this is how it worked from the beginning.
There was a problem hiding this comment.
"no value" implied 1. A=A is misleading and to make it makes no sense. If you specify -DA on the CLI it will still show just as A.
See also https://trac.cppcheck.net/ticket/14458.
There was a problem hiding this comment.
And see also https://trac.cppcheck.net/ticket/14166.
52f76ef to
b87ba98
Compare
|
getConfig is updated into returning configs:
Expected testresults updated accordingly and 2 new issue specific tests added to testpreprocessor.cpp |
b87ba98 to
caa892a
Compare
Good catch. The existing tests indirectly tested it, but no test that specifically test. Added new test. |
* Updated so that getConfig extracts ifdefs and if defined as itself, example X=X, and for all else just X * Updated hasDefine checker to detect configs even in pattern X=X
* Updated expected results from getConfigs according to defines X=X, else X * Added two TestPreprocessor tests, getConfigsIssue14317 & getCodeIssue1431, verifying issue 14317 fixed.
…Config. * Added checks that makes sure that no duplicated of a configuration (like X & X=X, in that case only X is kept) ends up in getConfig ret.
caa892a to
cc4c880
Compare
|
|
This introduced a regression: https://trac.cppcheck.net/ticket/14455#ticket |



Changed so that auto-configured values (without specified values) are set to itself instead of 1.
From issue 14317
isless=islesss
instead of
isless=1