@@ -251,11 +251,17 @@ let parse_property_attribute attr property =
251
251
| Some {Parsetree. attr_name = {txt; loc} ; attr_payload = payload } ->
252
252
parse_ids_payload txt loc
253
253
~default: Default_check
254
- ~empty: (Check { property; strict = false ; assume = false ; loc; } )
254
+ ~empty: (Check { property; strict = false ; loc; } )
255
255
[
256
- [" assume" ], Check { property; strict = false ; assume = true ; loc; };
257
- [" strict" ], Check { property; strict = true ; assume = false ; loc; };
258
- [" assume" ; " strict" ], Check { property; strict = true ; assume = true ; loc; };
256
+ [" assume" ],
257
+ Assume { property; strict = false ; never_returns_normally = false ; loc; };
258
+ [" strict" ], Check { property; strict = true ; loc; };
259
+ [" assume" ; " strict" ],
260
+ Assume { property; strict = true ; never_returns_normally = false ; loc; };
261
+ [" assume" ; " never_returns_normally" ],
262
+ Assume { property; strict = false ; never_returns_normally = true ; loc; };
263
+ [" assume" ; " strict" ; " never_returns_normally" ],
264
+ Assume { property; strict = true ; never_returns_normally = true ; loc; };
259
265
[" ignore" ], Ignore_assert_all property
260
266
]
261
267
payload
@@ -303,15 +309,15 @@ let get_property_attribute l p =
303
309
(match attr, res with
304
310
| None , Default_check -> ()
305
311
| _ , Default_check -> ()
306
- | None , (Check _ | Ignore_assert_all _ ) -> assert false
312
+ | None , (Check _ | Assume _ | Ignore_assert_all _ ) -> assert false
307
313
| Some _ , Ignore_assert_all _ -> ()
308
- | Some attr , Check { assume; _ } ->
314
+ | Some _ , Assume _ -> ()
315
+ | Some attr , Check _ ->
309
316
if ! Clflags. zero_alloc_check && ! Clflags. native_code then
310
317
(* The warning for unchecked functions will not trigger if the check is requested
311
318
through the [@@@zero_alloc all] top-level annotation rather than through the
312
319
function annotation [@zero_alloc]. *)
313
- if not assume then
314
- Builtin_attributes. register_property attr.attr_name);
320
+ Builtin_attributes. register_property attr.attr_name);
315
321
res
316
322
317
323
let get_poll_attribute l =
@@ -414,7 +420,8 @@ let assume_zero_alloc attributes =
414
420
match parse_property_attribute attr p with
415
421
| Default_check -> false
416
422
| Ignore_assert_all _ -> false
417
- | Check { property = Zero_alloc ; assume } -> assume
423
+ | Assume { property = Zero_alloc ; _ } -> true
424
+ | Check { property = Zero_alloc ; _ } -> false
418
425
419
426
let assume_zero_alloc attributes =
420
427
(* This function is used for "look-ahead" to find attributes
@@ -428,9 +435,12 @@ let add_check_attribute expr loc attributes =
428
435
| Zero_alloc -> " zero_alloc"
429
436
in
430
437
let to_string = function
431
- | Check { property; strict; assume; loc = _ } ->
432
- Printf. sprintf " %s %s%s"
433
- (if assume then " assume" else " assert" )
438
+ | Check { property; strict; loc = _ } ->
439
+ Printf. sprintf " assert %s%s"
440
+ (to_string property)
441
+ (if strict then " strict" else " " )
442
+ | Assume { property; strict; loc = _ } ->
443
+ Printf. sprintf " assume %s%s"
434
444
(to_string property)
435
445
(if strict then " strict" else " " )
436
446
| Ignore_assert_all property ->
@@ -441,11 +451,13 @@ let add_check_attribute expr loc attributes =
441
451
| Lfunction ({ attr = { stub = false } as attr ; } as funct ) ->
442
452
begin match get_property_attribute attributes Zero_alloc with
443
453
| Default_check -> expr
444
- | (Ignore_assert_all p | Check { property = p ; _ } ) as check ->
454
+ | (Ignore_assert_all p | Check { property = p; _ } | Assume { property = p; _ })
455
+ as check ->
445
456
begin match attr.check with
446
457
| Default_check -> ()
447
458
| Ignore_assert_all p'
448
- | Check { property = p' ; strict = _ ; assume = _ ; loc = _ ; } ->
459
+ | Assume { property = p'; strict = _; loc = _; }
460
+ | Check { property = p' ; strict = _ ; loc = _ ; } ->
449
461
if p = p' then
450
462
Location. prerr_warning loc
451
463
(Warnings. Duplicated_attribute (to_string check));
0 commit comments