File: w47_inline.ml

package info (click to toggle)
ocaml 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,396; asm: 5,462; makefile: 3,679; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (49 lines) | stat: -rw-r--r-- 1,250 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(* TEST_BELOW
(* Blank lines added here to preserve locations. *)







*)

let a = (fun x -> x) [@inline] (* accepted *)
let b = (fun x -> x) [@inline never] (* accepted *)
let c = (fun x -> x) [@inline always] (* accepted *)
let d = (fun x -> x) [@inline malformed attribute] (* rejected *)
let e = (fun x -> x) [@inline malformed_attribute] (* rejected *)
let f = (fun x -> x) [@inline : malformed_attribute] (* rejected *)
let g = (fun x -> x) [@inline ? malformed_attribute] (* rejected *)

let h x = (a [@inlined]) x (* accepted *)
let i x = (a [@inlined never]) x (* accepted *)
let j x = (a [@inlined always]) x (* accepted *)
let k x = (a [@inlined malformed]) x (* rejected *)

let l x = x [@@inline] (* accepted *)


let test x =
  let[@local always] f1 x = x (* ok *) in
  let[@local never] f2 x = x (* ok *) in
  let[@local malformed] f3 x = x (* bad payload *) in
  let[@local] f4 x = 2 * x (* not local *) in
  let[@local] f5 x = f1 x (* ok *) in
  let[@local] f6 x = 3 * x (* ok *) in
  let r =
    if x = 1 then f1 x
    else if x = 2 then f4 x
    else if x = 3 then f1 x
    else f5 x
  in
  f4 (f6 r)

(* TEST
 flags = "-w +A-70";
 setup-ocamlc.byte-build-env;
 compile_only = "true";
 ocamlc.byte;
 check-ocamlc.byte-output;
*)