Hi Andreas,

Normal typedef's are checked by structure.  To get checking by name, you
want to use abstract types.  Splint supports this using the /*@abstract@*/
annotation in the type definition.  For example:

typedef /*@abstract@*/ int Type1;
typedef /*@abstract@*/ int Type2;

/*@noaccess Type1, Type2@*/
void test() {
   Type1 a = 0;
   Type2 b = 0;
   a=b;
}

You will get warnings for the assignment (as well as the initializations).
You need the /*@noaccess Type1, Type2@*/, since by default code in the
file that defines the types is permitted to access the type
representations.

See Section 4.3 of the Splint manual for information on Splint's support
for abstract types (http://www.splint.org/manual/html/sec4.html).

--- Dave

On Fri, 12 Apr 2002, Andreas Rasmusson wrote:

> Hi,
>
> Is it possible to get warnings if two typedef:ed integer types are
> assigned to eachother?
> I.e i would like a warning when assigning a=b in the example below.
>
> cheers,
> Andreas
>
> Example Program:
> --------------------
> typedef int Type1;
> typedef int Type2;
> void test() {
>   Type1 a = 0;
>   Type2 b = 0;
>   a=b;
> }
> --------------------
>
> Splint output:
> -------------------
>  > splint test.c
> Splint 3.0.1.6 --- 27 Mar 2002
>
> Finished checking --- no warnings
>  >
> -------------------
>
>

Reply via email to