My client has 200KLOC of working code on an architecture where char is 8 bits, short is 16 bits, and int and long are 32 bits. They want to port to C55x where char, short and int are all 16 bits, and long is 32 bits. The source for the most part looks reasonably well written C90 code, however I have discovered code which relies on the current architecture. For example:
unsigned char c;
unsigned short s1, s2;
unsigned long l;
/* Mask to 8 bits */
c = (unsigned char)l;
/* May overflow on C55x */
l = s1 + s2;
Does anyone know of tools that can draw attention to code that works on the current architecture, but probably won't on C55x?
To be more specific, I'm looking for a tool or tools that will locate code where:
1. a short, int or long is implicitly or explicitly demoted to char;
2. a binary operation that could cause overflow (* + - << *= += -= <<=) occurs between any two integer types except long, and the result is placed in either an int or a long;
3. a unary operation that could cause overflow (- ++ --) occurs on int and
4. casts occur between char * and other pointer types.
The preceding paragraph specifies type widths only, not signedness or qualification or the lack of either.
I have already tried splint and gcc under cygwin. I don't think they can be made to do what I want. I don't believe gcc is available for C55x. I've searched web descriptions of static analysers, but so far have not found anything that helps.