(* -------------------------------------------------- *)
(* todo: should analyse the 's' for int to know if unsigned or not *)
- | Constant (String (s,kind)) -> make_info_def (type_of_s "char *")
- | Constant MultiString _ -> make_info_def (type_of_s "char *")
+ | Constant (String (s,kind)) -> make_info_def (type_of_s "char []")
+ | Constant MultiString _ -> make_info_def (type_of_s "char []")
| Constant (Char (s,kind)) -> make_info_def (type_of_s "char")
| Constant (Int (s,kind)) ->
(* this seems really unpleasant, but perhaps the type needs to be set
(* 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
| Unary (e, Not) ->
k expr; (* recurse to set the types-ref of sub expressions *)
- Ast_c.get_type_expr e
+ (* the result of ! is always 0 or 1, not the argument type *)
+ make_info_def (type_of_s "int")
| Unary (e, Tilde) ->
k expr; (* recurse to set the types-ref of sub expressions *)
Ast_c.get_type_expr e