Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate FunctionNoParams as a function without parameters. #459

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. *)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(As below, this is ok as a workaround, but FunctionNoParams has to be treated specially, in the Cerberus frontend before CN.)

| 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 (!^"Unsupported C-type" ^^^ Cerb_frontend.Pp_core_ctype.pp_ctype ct)


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