According to the MISRA feature matrix, the MISRA add-on for cppcheck should check rule 5.3, which states that an identifier declared in an inner scope shall not hide an identifier declared in an outer scope. However, I don't get any issues reported when I check the following code:
According to the MISRA feature matrix, the MISRA add-on for cppcheck should check rule 5.3, which states that an identifier declared in an inner scope shall not hide an identifier declared in an outer scope. However, I don't get any issues reported when I check the following code:
I am running this using:
where my misra.json file looks like this:
Am I not running the add-on correctly?
Can you add the
--enable=style
please this particular warning is provided by core cppcheck and I think the message id is shadowVariable.Looks like there has been a regression in cppcheck since https://github.com/chrchr-github/cppcheck/commit/3ef1212448aab2197ca8b58099b86fee68665c36
Last edit: CHR 2022-05-04
I have checked also your file, t.c, with option
--enable=style
:and it returns just:
Being "misra.jon":
Regarding 5.3 rule, this is not checked by Misra addon, it is checked by cppcheck itself, as it states here: http://cppcheck.net/misra.php
BTW, I take a pure example from MISRA pdf:
And, running the same command, it returns:
It seems the first 3 comments refers to this rule, 5.3, and last comment refers to other rule, and it seems to be ok.
The problem in cppcheck has been fixed with https://github.com/danmar/cppcheck/pull/4079
Thanks CHR!