Skip to content

Commit

Permalink
Translate FunctionNoParams as a function without parameters.
Browse files Browse the repository at this point in the history
Fixes #438
  • Loading branch information
yav authored and cp526 committed Aug 5, 2024
1 parent 45ba16b commit 70f8e61
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/cn/lib/sctypes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ let rec of_ctype (Ctype.Ctype (_, ct_)) =
in
let@ ret_ct = of_ctype ret_ct in
return (Function ((ret_q, ret_ct), args, variadic))
| Ctype.FunctionNoParams _ -> fail

(* The meaning of a function with no parameters depends on the version of C,
but here we treat it as if it really has no parameter (i.e., like `void`)
which is what more recent versions of the standard do. *)
| Ctype.FunctionNoParams (ret_q, ret_ct) ->
let@ ret_ct = of_ctype ret_ct in
return (Function ((ret_q, ret_ct), [], false))

| Ctype.Pointer (_qualifiers, ctype) ->
let@ t = of_ctype ctype in
return (Pointer t)
Expand All @@ -184,7 +191,7 @@ let of_ctype_unsafe loc ct =
let open Cerb_pp_prelude in
match of_ctype ct with
| Some ct -> ct
| None -> Tools.unsupported loc (!^"C-type" ^^^ Cerb_frontend.Pp_core_ctype.pp_ctype ct)
| None -> Tools.unsupported loc (!^"YAV C-type" ^^^ Cerb_frontend.Pp_core_ctype.pp_ctype ct)


let pp t = Pp_core_ctype.pp_ctype (to_ctype t)
Expand Down

0 comments on commit 70f8e61

Please sign in to comment.