diff options
Diffstat (limited to 'parsing/builtin_attributes.ml')
-rwxr-xr-x | parsing/builtin_attributes.ml | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/parsing/builtin_attributes.ml b/parsing/builtin_attributes.ml index a8eb33b607..57b5d4612d 100755 --- a/parsing/builtin_attributes.ml +++ b/parsing/builtin_attributes.ml @@ -62,11 +62,22 @@ let rec error_of_extension ext = let cat s1 s2 = if s2 = "" then s1 else s1 ^ "\n" ^ s2 -let rec deprecated_of_attrs = function +let deprecated_attr x = + match x with + | ({txt = "ocaml.deprecated"|"deprecated"; _},_) -> Some x + | _ -> None + +let rec deprecated_attrs = function | [] -> None - | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_of_attrs tl + | hd :: tl -> + match deprecated_attr hd with + | Some x -> Some x + | None -> deprecated_attrs tl + +let deprecated_of_attrs l = + match deprecated_attrs l with + | None -> None + | Some (_,p) -> Some (string_of_opt_payload p) let check_deprecated loc attrs s = match deprecated_of_attrs attrs with @@ -117,6 +128,12 @@ let rec deprecated_of_str = function | _ -> None +let check_no_deprecated attrs = + match deprecated_attrs attrs with + | None -> () + | Some ({txt;loc},_) -> + Location.prerr_warning loc (Warnings.Misplaced_attribute txt) + let warning_attribute ?(ppwarning = true) = let process loc txt errflag payload = match string_of_payload payload with |