Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug with warning 199 and -stop-after typing #2513

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ocaml/driver/compile_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,10 @@ let implementation ~hook_parse_tree ~hook_typed_tree info ~backend =
let typed = typecheck_impl info parsed in
hook_typed_tree typed;
if Clflags.(should_stop_after Compiler_pass.Typing) then () else begin
backend info typed
backend info typed;
end;
end;
Builtin_attributes.warn_unchecked_property ();
if not (Clflags.(should_stop_after Compiler_pass.Selection)) then
Builtin_attributes.warn_unchecked_property ();
Warnings.check_fatal ();
)
7 changes: 7 additions & 0 deletions tests/backend/checkmach/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -850,3 +850,10 @@
(enabled_if (= %{context_name} "main"))
(deps test_arity.output test_arity.output.corrected)
(action (diff test_arity.output test_arity.output.corrected)))

(rule
(alias runtest)
(deps stop_after_typing.ml)
(target stop_after_typing.cmi)
(enabled_if (= %{context_name} "main"))
(action (run %{bin:ocamlopt.opt} stop_after_typing.ml -g -c -stop-after typing -O3 -warn-error +a)))
19 changes: 19 additions & 0 deletions tests/backend/checkmach/gen/gen_dune.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ let () =
${enabled_if}
(deps ${deps})
(action (run %{bin:ocamlopt.opt} %{deps} -g -c ${extra_flags} -dcse -dcheckmach -dump-into-file -O3 -warn-error +a)))
|};
Buffer.output_buffer Out_channel.stdout buf
in
let print_cmi_target name =
let subst = function
| "enabled_if" -> enabled_if
| "name" -> name
| _ -> "assert false"
in
Buffer.clear buf;
Buffer.add_substitute buf subst
{|
(rule
(alias runtest)
(deps ${name}.ml)
(target ${name}.cmi)
${enabled_if}
(action (run %{bin:ocamlopt.opt} ${name}.ml -g -c -stop-after typing -O3 -warn-error +a)))
|};
Buffer.output_buffer Out_channel.stdout buf
in
Expand Down Expand Up @@ -140,4 +158,5 @@ let () =
~extra_dep:None ~exit_code:2 "test_all_opt3";
print_test_expected_output ~cutoff:default_cutoff
~extra_dep:None ~exit_code:2 "test_arity";
print_cmi_target "stop_after_typing";
()
4 changes: 4 additions & 0 deletions tests/backend/checkmach/stop_after_typing.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(* This just checks we don't get a warning 199 (unchecked zero alloc attribute)
if we stop after typing. *)

let[@zero_alloc] f x = x
Loading