Skip to content

Commit 2c99cc4

Browse files
committed
Add a test
1 parent 9b2fa69 commit 2c99cc4

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

tests/backend/checkmach/dune.inc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,22 @@
578578
(enabled_if (= %{context_name} "main"))
579579
(deps test_zero_alloc_opt2.ml)
580580
(action (run %{bin:ocamlopt.opt} %{deps} -g -c -zero-alloc-check opt -dcse -dcheckmach -dump-into-file -O3)))
581+
582+
(rule
583+
(enabled_if (= %{context_name} "main"))
584+
(targets test_misplaced_attr.output.corrected)
585+
(deps (:ml test_misplaced_attr.ml) filter.sh)
586+
(action
587+
(with-outputs-to test_misplaced_attr.output.corrected
588+
(pipe-outputs
589+
(with-accepted-exit-codes 0
590+
(run %{bin:ocamlopt.opt} %{ml} -g -color never -error-style short -c
591+
-zero-alloc-check default -checkmach-details-cutoff 20 -O3))
592+
(run "./filter.sh")
593+
))))
594+
595+
(rule
596+
(alias runtest)
597+
(enabled_if (= %{context_name} "main"))
598+
(deps test_misplaced_attr.output test_misplaced_attr.output.corrected)
599+
(action (diff test_misplaced_attr.output test_misplaced_attr.output.corrected)))

tests/backend/checkmach/gen/gen_dune.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ let () =
124124
print_test_expected_output ~extra_flags:"-zero-alloc-check opt" ~cutoff:default_cutoff ~flambda_only:true ~extra_dep:None ~exit_code:2 "fail23";
125125
print_test ~extra_flags:"-zero-alloc-check opt" ~flambda_only:false "test_zero_alloc_opt1.ml";
126126
print_test ~extra_flags:"-zero-alloc-check opt" ~flambda_only:false "test_zero_alloc_opt2.ml";
127+
print_test_expected_output ~cutoff:default_cutoff ~flambda_only:false ~extra_dep:None ~exit_code:0 "test_misplaced_attr";
127128
()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let[@zero_alloc assume] foo =
2+
let x = 42 in
3+
fun z -> z + x
4+
5+
let[@zero_alloc] bar =
6+
let x = 42 in
7+
fun z -> z + x
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
File "test_misplaced_attr.ml", line 1, characters 5-15:
2+
Warning 53 [misplaced-attribute]: the "zero_alloc" attribute cannot appear in this context
3+
4+
File "test_misplaced_attr.ml", line 5, characters 5-15:
5+
Warning 53 [misplaced-attribute]: the "zero_alloc" attribute cannot appear in this context

0 commit comments

Comments
 (0)