Permalink
Browse files

ocaml.warnerror built-in attribute.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14753 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
1 parent 0736512 commit 7e2333051a354dfe84420c89a072ed1de6e53206 @alainfrisch alainfrisch committed May 6, 2014
Showing with 20 additions and 19 deletions.
  1. +20 −19 typing/typetexp.ml
View
@@ -88,27 +88,28 @@ let warning_leave_scope () =
let warning_attribute attrs =
let prev_warnings = List.hd !warning_scope in
+ let process loc txt errflag payload =
+ match string_of_payload payload with
+ | Some s ->
+ if !prev_warnings = None then
+ prev_warnings := Some (Warnings.backup ());
+ begin try Warnings.parse_options errflag s
+ with Arg.Bad _ ->
+ Location.prerr_warning loc
+ (Warnings.Attribute_payload
+ (txt, "Ill-formed list of warnings"))
+ end
+ | None ->
+ Location.prerr_warning loc
+ (Warnings.Attribute_payload
+ (txt, "A single string literal is expected"))
+ in
List.iter
(function
- | ({txt = "ocaml.warning"|"warning"; loc}, payload) ->
- begin match payload with
- | PStr [{pstr_desc=Pstr_eval
- ({pexp_desc=Pexp_constant(Const_string(s, _))}, _)}] ->
- if !prev_warnings = None then
- prev_warnings := Some (Warnings.backup ());
- begin try Warnings.parse_options false s
- with Arg.Bad _ ->
- Location.prerr_warning loc
- (Warnings.Attribute_payload
- ("ocaml.warning",
- "Ill-formed list of warnings"))
- end
- | _ ->
- Location.prerr_warning loc
- (Warnings.Attribute_payload
- ("ocaml.warning",
- "A single string literal is expected"))
- end
+ | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) ->
+ process loc txt false payload
+ | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) ->
+ process loc txt true payload
| _ ->
()
)

0 comments on commit 7e23330

Please sign in to comment.