Skip to content

Commit 7803705

Browse files
authored
flambda-backend: Cause a C warning when CAMLreturn is missing in C stubs. (#376)
1 parent 6199db5 commit 7803705

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

runtime/caml/memory.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ struct caml__roots_block {
297297
*/
298298

299299
#define CAMLparam0() \
300+
int caml__missing_CAMLreturn = 0; \
300301
struct caml__roots_block *caml__frame = Caml_state_field(local_roots)
301302

302303
#define CAMLparam1(x) \
@@ -456,7 +457,10 @@ struct caml__roots_block {
456457
CAMLxparamN (x, (size))
457458

458459

459-
#define CAMLdrop Caml_state_field(local_roots) = caml__frame
460+
#define CAMLdrop do { \
461+
(void)caml__missing_CAMLreturn; \
462+
Caml_state_field(local_roots) = caml__frame; \
463+
} while (0)
460464

461465
#define CAMLreturn0 do{ \
462466
CAMLdrop; \
@@ -471,7 +475,7 @@ struct caml__roots_block {
471475

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

474-
#define CAMLnoreturn ((void) caml__frame)
478+
#define CAMLnoreturn ((void) caml__missing_CAMLreturn, (void) caml__frame)
475479

476480

477481
/* convenience macro */

0 commit comments

Comments
 (0)