Here is a patch, against version 0.2.4rc2. I have takenthe strategy that
if nothing is known about the type of the left hand side of the
assignment, then it uses the type of the assignment. This is not
completely correct, and I can change it if it seems to cause problems, but
otherwise there will be no type information at all in a case like
x->y = ...
when the structure definition for the type of x is not in the same file or
an included header file.
julia
diff -u -p a/parsing_c/type_annoter_c.ml b/parsing_c/type_annoter_c.ml
--- a/parsing_c/type_annoter_c.ml 2010-08-29 15:08:31.000000000 +0200
+++ b/parsing_c/type_annoter_c.ml 2010-08-29 15:09:24.000000000 +0200
@@ -860,8 +860,12 @@ let annotater_expr_visitor_subpart = (fu
(* todo? lub, hmm maybe not, cos type must be e1 *)
| Assignment (e1, op, e2) ->
k expr;
- (* value of an assignment is the value of the RHS expression *)
- Ast_c.get_type_expr e2
+ (* value of an assignment is the value of the RHS expression, but its
+ type is the type of the lhs expression. Use the rhs exp if no
+ information is available *)
+ (match Ast_c.get_type_expr e1 with
+ (None,_) -> Ast_c.get_type_expr e2
+ | (Some ty,t) -> (Some ty,t))
| Sequence (e1, e2) ->
k expr;
Ast_c.get_type_expr e2
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)