Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e6889aa3 authored by Thierry Martinez's avatar Thierry Martinez
Browse files

Fix conversion to pointer arithmetic

parent feb58d03
No related branches found
No related tags found
No related merge requests found
Pipeline #742145 failed
......@@ -596,10 +596,17 @@ with type 'a Applicative.t = 'a Applicative.t = struct
{ record_decl with fields = name_anonymous_fields record_decl.fields },
Free_monoid.zero
let is_pointer_type (ty : Clang.Type.t) =
match ty.desc with
| Pointer _ -> true
| _ -> false
let is_array (expr : Clang.Expr.t) =
let cursor = Clang.Ast.cursor_of_node expr in
match Clang.ext_get_cursor_kind cursor with
| ImplicitCastExpr ->
let child = Option.get (Clang.first_child cursor) in
begin match Clang.get_type_kind (Clang.get_cursor_type child) with
| ConstantArray -> true
| _ -> false
end
| _ ->
false
let hook :
type a . a Refl.refl -> (a -> env -> a * accu) -> (a -> env -> a * accu) =
......@@ -632,7 +639,7 @@ with type 'a Applicative.t = 'a Applicative.t = struct
| UnaryExpr { kind = SizeOf; argument } ->
visit_unary_expr_size_of argument env
| ArraySubscript { base; index }
when is_pointer_type (Clang.Type.of_node base) ->
when not (is_array base) ->
let x' : Clang.Ast.expr_desc = UnaryOperator {
kind = Deref;
operand = { base with desc = BinaryOperator {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment