cstatic-analysiscomplex-numberssplint

splint failing on code that includes complex.h


I'm trying to run splint on a C source that includes complex.h from the standard C library to support complex arithmetic.

Unfortunately, splint fails with the following error.

Splint 3.1.2 --- 03 May 2009

/usr/include/bits/cmathcalls.h:54:31: Parse Error: Non-function declaration: _Complex : extern double. (For help on parse errors, see splint -help parseerrors.) *** Cannot continue.

Googling for the problem resulted in only this message on the split-discuss mailing list (which remains unanswered).

Any ideas?

Update

Here is a very simple example of a failing source:

#include <complex.h>

int main() {
  complex x = 2 + 8i;
  x = x + 1;
}

Attempts to redefine the unsupported _Complex C99 Keyword leads to an error with the imaginary part of the complex number (which isn't surprising I suppose).

lsc@deepthought:~$ splint-D_Complex=double temp.c  
Splint 3.1.2 --- 03 May 2009

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

Solution

  • I eventually solved this by temporarily overriding complex.h with a dummy one when calling splint.

    [lsc@home]$ ls /opt/qa_tools/utils/splint_includes/
    complex.h
    
    [lsc@home]$ splint -I/opt/qa_tools/utils/splint_includes test.c
    Splint 3.1.1 --- 15 Jun 2004
    
    Finished checking --- no warnings
    

    The dummy complex.h file suppresses the relevant keywords and replaces constants/functions with dummy ones. These keywords/constants/functions were gleaned from the specs

    A copy of this file is available here: https://gist.github.com/1316366