[Cocci] RE: Coccinelle errors during parsing of C-macros

Klaus.K Pedersen (Nokia-D/Beijing) klaus.k.pedersen at nokia.com
Wed Apr 29 14:37:43 CEST 2009


On Wed, 2009-04-29 at 12:24 +0200, ext Julia Lawall wrote:
> Here is a patch for better type inference of integer constant.  It should 
> be applied after the previous one.
> 
[...]
> +	| ["l"] ->	make_info_def (type_of_s "long")
> +	| ["u"] ->	make_info_def (type_of_s "unsigned long")

"34u" should be treated as a unsigned int, not long, 65536u should
be treated as unsigned int or unsigned long depending on the size 
of the int (32 or 16 bit).

>From Draft ANSI C Standard (ANSI X3J11/88-090)
http://flash-gordon.me.uk/ansi.c.txt
"The type of an integer constant is the first of the corresponding
list in which its value can be represented.  Unsuffixed decimal: int,
long int, unsigned long int; unsuffixed octal or hexadecimal: int,
unsigned int, long int, unsigned long int; suffixed by the letter u
or U: unsigned int, unsigned long int; suffixed by the letter l or
L: long int, unsigned long int; suffixed by both the letters u or U
and l or L: unsigned long int ."


BR, Klaus


> +	| _ ->    	make_info_def (type_of_s "int"))
>      | Constant (Float (s,kind)) -> 
>          let fake = Ast_c.fakeInfo (Common.fake_parse_info) in
>          let fake = Ast_c.rewrap_str "float" fake in
> _______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)



More information about the Cocci mailing list