@@ -404,6 +404,15 @@ let primitives_table =
404404
405405let find_primitive prim_name = Hashtbl. find primitives_table prim_name
406406
407+ let warn_on_polymorphic_comparison loc = function
408+ | Pobjcomp _ | Pobjorder | Pobjmin | Pobjmax ->
409+ Location. prerr_warning loc Warnings. Bs_polymorphic_comparison
410+ | _ -> ()
411+
412+ let emit_primitive_warnings loc primitive =
413+ warn_on_polymorphic_comparison loc primitive;
414+ primitive
415+
407416let specialize_comparison
408417 ({objcomp; intcomp; floatcomp; stringcomp; bigintcomp; boolcomp} :
409418 specialized ) env ty =
@@ -444,8 +453,9 @@ let specialize_primitive p env ty (* ~has_constant_constructor *) =
444453let transl_primitive loc p env ty =
445454 (* Printf.eprintf "----transl_primitive %s----\n" p.prim_name; *)
446455 let prim =
447- try specialize_primitive p env ty (* ~has_constant_constructor:false *)
448- with Not_found -> Pccall p
456+ (try specialize_primitive p env ty (* ~has_constant_constructor:false *)
457+ with Not_found -> Pccall p)
458+ |> emit_primitive_warnings loc
449459 in
450460 match prim with
451461 | Ploc kind -> (
@@ -492,7 +502,7 @@ let transl_primitive_application loc prim env ty args =
492502 | [arg1] | [arg1; _] -> translate_unified_ops prim env arg1.exp_type
493503 | _ -> None
494504 in
495- match unified with
505+ ( match unified with
496506 | Some primitive -> primitive
497507 | None -> (
498508 try
@@ -524,7 +534,8 @@ let transl_primitive_application loc prim env ty args =
524534 with Not_found ->
525535 if String. length prim_name > 0 && prim_name.[0 ] = '%' then
526536 raise (Error (loc, Unknown_builtin_primitive prim_name));
527- Pccall prim)
537+ Pccall prim))
538+ |> emit_primitive_warnings loc
528539
529540(* To propagate structured constants *)
530541
@@ -653,8 +664,10 @@ let extract_directive_for_fn exp =
653664 else None )
654665
655666let rec transl_exp e =
656- List. iter (Translattribute. check_attribute e) e.exp_attributes;
657- transl_exp0 e
667+ Builtin_attributes. warning_scope ~ppwarning: false
668+ ~report_attribute_errors: false e.exp_attributes (fun () ->
669+ List. iter (Translattribute. check_attribute e) e.exp_attributes;
670+ transl_exp0 e)
658671
659672and transl_exp0 (e : Typedtree.expression ) : Lambda.lambda =
660673 match e.exp_desc with
0 commit comments