Skip to content

Commit b9fe5cb

Browse files
committed
Cause a C warning when CAMLreturn is missing in C stubs.
1 parent 84745b5 commit b9fe5cb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ocaml/runtime/caml/memory.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ struct caml__roots_block {
292292
*/
293293

294294
#define CAMLparam0() \
295+
int caml__missing_CAMLreturn = 0; \
295296
struct caml__roots_block *caml__frame = Caml_state_field(local_roots)
296297

297298
#define CAMLparam1(x) \
@@ -451,7 +452,10 @@ struct caml__roots_block {
451452
CAMLxparamN (x, (size))
452453

453454

454-
#define CAMLdrop Caml_state_field(local_roots) = caml__frame
455+
#define CAMLdrop do { \
456+
(void)caml__missing_CAMLreturn; \
457+
Caml_state_field(local_roots) = caml__frame; \
458+
} while (0)
455459

456460
#define CAMLreturn0 do{ \
457461
CAMLdrop; \
@@ -466,7 +470,7 @@ struct caml__roots_block {
466470

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

469-
#define CAMLnoreturn ((void) caml__frame)
473+
#define CAMLnoreturn ((void) caml__missing_CAMLreturn, (void) caml__frame)
470474

471475

472476
/* convenience macro */

0 commit comments

Comments
 (0)