Skip to content

Commit

Permalink
When the payload of the ocaml.deprecated attribute is a string, repor…
Browse files Browse the repository at this point in the history
…t it as part of the warning message.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14751 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information
alainfrisch committed May 6, 2014
1 parent 85a1763 commit 110e97d
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions typing/typetexp.ml
Expand Up @@ -55,15 +55,25 @@ type error =

exception Error of Location.t * Env.t * error

let string_of_cst = function
| Const_string(s, _) -> Some s
| _ -> None

let string_of_payload = function
| PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] ->
string_of_cst c
| _ -> None

let check_deprecated loc attrs s =
if
List.exists
(function
| ({txt = "ocaml.deprecated"|"deprecated"; _}, _) -> true
| _ -> false)
attrs
then
Location.prerr_warning loc (Warnings.Deprecated s)
List.iter
(function
| ({txt = "ocaml.deprecated"|"deprecated"; _}, p) ->
begin match string_of_payload p with
| Some txt -> Location.prerr_warning loc (Warnings.Deprecated (s ^ "\n" ^ txt))
| None -> Location.prerr_warning loc (Warnings.Deprecated s)
end
| _ -> ())
attrs

let warning_attribute attrs =
let prev_warnings = ref None in
Expand Down

0 comments on commit 110e97d

Please sign in to comment.