splintchecker/splint

Allow declaring variables in the middle of a block.

Opened this issue · 2 comments

If I check this input:

void foo() {
  int x = 7;
  foo();
  int y = 5;
}

I get the error:

Splint 3.1.2 --- 20 Feb 2009

junk.c:4:6: Parse Error. (For help on parse errors, see splint -help
               parseerrors.)
*** Cannot continue.

This is similar to issue #12. It is not easy to fix.

With the last version of splint (compiled from a28a60f) I have no error on the same code:

Splint 3.1.2 --- 17 Jan 2021

junk.c: (in function foo)
junk.c:2:7: Variable x declared but not used
  A variable is declared but never used. Use /*@unused@*/ in front of
  declaration to suppress message. (Use -varuse to inhibit warning)
junk.c:4:7: Variable y declared but not used
junk.c:1:6: Function exported but not used outside junk: foo
  A declaration is exported, but not used outside this module. Declaration can
  use static qualifier. (Use -exportlocal to inhibit warning)
   junk.c:5:1: Definition of foo

Finished checking --- 3 code warnings

I don't know if there were any developments on this subject since the version Splint 3.1.2 --- 20 Feb 2009.
If it is so, I think we could close the issue.