splintchecker/splint

Enhancement: Support for C99 syntax

Opened this issue · 6 comments

C has grown since the days of K&R C, with new syntax and semantics. Could splint fix the parser to handle newer C code, such as variable declarations in loop initializer statements?

There was a patch for C99 declaration support floating around on the old sourceforge project mailing list (or the bug tracker... I don't remember).
But it also caused the number of shift/reduce conflicts in the bison grammar to explode and I've never tested it on C99 code myself.

On the other hand, splint has an extensive test suite that will likely catch the possible regressions caused by the grammar patch, so maybe someone brave could dig it out and make it work...

I thought I had applied this patch. At least support for variables declared part way through a function. Like for(int i = 0; i < 10; i++). Maybe I was just working on it. Part of the issue is not just the grammar. You also have to fix up spints management in the rules. Splint doesn't scale well when things are deeply nested, etc. For this reason I wanted to use a gcc plugin, which may solve many lex/parse issues.

See: https://gcc.gnu.org/c99status.html for list of what this may entail. Each item there is possibly weeks of work. I think the issue you specifically mention is "mixed declarations and code" which is the same as issue #7. Other features of c99 are useful as well. I think it is best to proceed with a compliance chart like this to say what is supported.

personally the C++-style comments is the C99 feature I think would be most helpful; the fact that splint doesn't support them (or at least didn't support them when I last checked) is (part of) why I opened this GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80529

I thought I had applied this patch. At least support for variables declared part way through a function. Like for(int i = 0; i < 10; i++). Maybe I was just working on it. Part of the issue is not just the grammar. You also have to fix up spints management in the rules. Splint doesn't scale well when things are deeply nested, etc. For this reason I wanted to use a gcc plugin, which may solve many lex/parse issues.

Hi bpringlemei, seems that master branch do not have this patch?