Skip to content

Commit

Permalink
Cause a C warning when CAMLreturn is missing in C stubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Nov 9, 2021
1 parent 84745b5 commit b9fe5cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ocaml/runtime/caml/memory.h
Expand Up @@ -292,6 +292,7 @@ struct caml__roots_block {
*/

#define CAMLparam0() \
int caml__missing_CAMLreturn = 0; \
struct caml__roots_block *caml__frame = Caml_state_field(local_roots)

#define CAMLparam1(x) \
Expand Down Expand Up @@ -451,7 +452,10 @@ struct caml__roots_block {
CAMLxparamN (x, (size))


#define CAMLdrop Caml_state_field(local_roots) = caml__frame
#define CAMLdrop do { \
(void)caml__missing_CAMLreturn; \
Caml_state_field(local_roots) = caml__frame; \
} while (0)

#define CAMLreturn0 do{ \
CAMLdrop; \
Expand All @@ -466,7 +470,7 @@ struct caml__roots_block {

#define CAMLreturn(result) CAMLreturnT(value, result)

#define CAMLnoreturn ((void) caml__frame)
#define CAMLnoreturn ((void) caml__missing_CAMLreturn, (void) caml__frame)


/* convenience macro */
Expand Down

0 comments on commit b9fe5cb

Please sign in to comment.