-
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 FP unusedStructMember #7004
base: main
Are you sure you want to change the base?
Conversation
@@ -1962,6 +1963,17 @@ class TestUnusedVar : public TestFixture { | |||
errout_str()); | |||
} | |||
|
|||
void structmember26() { | |||
checkStructMemberUsage("struct S {\n" |
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.
Either there are typos in the test case (s
-> S
), or I don't understand the FP.
As it stands, I would expect a warning for the given code.
Triggering while a function parameter has the same name as a struct member.
9a24c44
to
6d6254c
Compare
Either there are typos in the test case (`s` -> `S`), or I don't understand the FP.
As it stands, I would expect a warning for the given code.
Typo in test, fixed.
|
With your change applied, will we still warn about struct S { int a; };
struct T f(int a) {
struct T t = {.a = 1};
return t;
} |
With your change applied, will we still warn about `S::a`?
~~~c
struct S { int a; };
struct T f(int a) {
struct T t = {.a = 1};
return t;
}
~~~
Correct
|
With your change applied, will we still warn about `S::a`?
~~~c
struct S { int a; };
struct T f(int a) {
struct T t = {.a = 1};
return t;
}
~~~
My bad, must have tried this out on the wrong branch before. It does not
warn about S::a in the provided example anymore. Makes one wonder if the
a field in the initializer should really be flagged as a variable?
|
The root cause is likely the wrong varid:
|
There is this similar ticket: https://trac.cppcheck.net/ticket/13123 |
Triggering while a function parameter has the same name as a struct member.