Skip to content

Commit

Permalink
flambda-backend: Cause a C warning when CAMLreturn is missing in C st…
Browse files Browse the repository at this point in the history
…ubs. (ocaml#376)
  • Loading branch information
stedolan committed Feb 16, 2022
1 parent 6199db5 commit 7803705
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions runtime/caml/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,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 @@ -456,7 +457,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 @@ -471,7 +475,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 7803705

Please sign in to comment.