Skip to content

Commit 2ab8999

Browse files
authored
flambda-backend: Issue misplaced attribute warning earlier (#2155)
1 parent d9ae7eb commit 2ab8999

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

driver/compile.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ let to_bytecode i Typedtree.{structure; coercion; _} =
3636
(Translmod.transl_implementation i.module_name ~style:Set_global_to_block)
3737
|> Profile.(record ~accumulate:true generate)
3838
(fun { Lambda.code = lambda; required_globals } ->
39+
Builtin_attributes.warn_unused ();
3940
lambda
4041
|> print_if i.ppf_dump Clflags.dump_rawlambda Printlambda.lambda
4142
|> Simplif.simplify_lambda

driver/compile_common.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ let implementation ~hook_parse_tree ~hook_typed_tree info ~backend =
139139
backend info typed
140140
end;
141141
end;
142-
Builtin_attributes.warn_unused ();
142+
Builtin_attributes.warn_unchecked_property ();
143143
Warnings.check_fatal ();
144144
)

driver/optcompile.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ let compile i ~backend ~middle_end ~transl_style
4040
|> print_if i.ppf_dump Clflags.dump_rawlambda Printlambda.program
4141
|> Profile.(record generate)
4242
(fun program ->
43+
Builtin_attributes.warn_unused ();
4344
let code = Simplif.simplify_lambda program.Lambda.code in
4445
{ program with Lambda.code }
4546
|> print_if i.ppf_dump Clflags.dump_lambda Printlambda.program

parsing/builtin_attributes.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ let mark_property_checked txt loc =
3838
let register_property attr =
3939
Attribute_table.replace unchecked_properties attr ()
4040
let warn_unchecked_property () =
41+
(* When using -i, attributes will not have been translated, so we can't
42+
warn about missing ones. *)
43+
if !Clflags.print_types then ()
44+
else
4145
let keys = List.of_seq (Attribute_table.to_seq_keys unchecked_properties) in
4246
let keys = List.sort attr_order keys in
4347
List.iter (fun sloc ->
@@ -50,7 +54,6 @@ let warn_unused () =
5054
if !Clflags.print_types then ()
5155
else
5256
begin
53-
warn_unchecked_property ();
5457
let keys = List.of_seq (Attribute_table.to_seq_keys unused_attrs) in
5558
let keys = List.sort attr_order keys in
5659
List.iter (fun sloc ->

parsing/builtin_attributes.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ val mark_payload_attrs_used : Parsetree.payload -> unit
9292
(** Issue misplaced attribute warnings for all attributes created with
9393
[mk_internal] but not yet marked used. *)
9494
val warn_unused : unit -> unit
95+
val warn_unchecked_property : unit -> unit
9596

9697
val check_alerts: Location.t -> Parsetree.attributes -> string -> unit
9798
val check_alerts_inclusion:

0 commit comments

Comments
 (0)