@@ -54,6 +54,12 @@ let reset () = num_errors := 0; num_warnings := 0
5454
5555exception Abort
5656
57+ (* Locations are (filename, line number) pairs *)
58+
59+ let no_loc = (" " , - 1 )
60+
61+ let file_loc file = (file,- 10 )
62+
5763(* [fatal_error_raw] is identical to [fatal_error], except it uses [Printf]
5864 to print its message, as opposed to [Format], and does not automatically
5965 introduce indentation and a final dot into the message. This is useful
@@ -106,6 +112,7 @@ type warning_type =
106112 | Non_linear_cond_expr
107113 | Invalid_UTF8
108114 | Dollar_in_identifier
115+ | Unknown_warning
109116
110117(* List of all warnings with default status.
111118 "true" means the warning is active by default.
@@ -143,7 +150,8 @@ let all_warnings =
143150 (Reduced_alignment , false );
144151 (Non_linear_cond_expr , false );
145152 (Invalid_UTF8 , true );
146- (Dollar_in_identifier , false )
153+ (Dollar_in_identifier , false );
154+ (Unknown_warning , true )
147155 ]
148156
149157(* List of active warnings *)
@@ -188,6 +196,7 @@ let string_of_warning = function
188196 | Non_linear_cond_expr -> " non-linear-cond-expr"
189197 | Invalid_UTF8 -> " invalid-utf8"
190198 | Dollar_in_identifier -> " dollar-in-identifier-extension"
199+ | Unknown_warning -> " unknown-warning-option"
191200
192201(* Activate the given warning *)
193202let activate_warning w () =
@@ -363,13 +372,15 @@ let check_errors () =
363372 raise Abort
364373 end
365374
375+ let unknown_warning w =
376+ warning no_loc Unknown_warning " Unknown warning option %s, ignored." w
366377
367378let error_option w =
368379 let key = string_of_warning w in
369380 [Exact (" -W" ^ key), Unit (activate_warning w);
370381 Exact (" -Wno-" ^ key), Unit (deactivate_warning w);
371382 Exact (" -Werror=" ^ key), Unit (warning_as_error w);
372- Exact (" -Wno-error=" ^ key), Unit ( warning_not_as_error w)]
383+ Exact (" -Wno-error=" ^ key), Unit (warning_not_as_error w)]
373384
374385let warning_options =
375386 List. concat (List. map (fun (w , active ) -> error_option w) all_warnings) @
@@ -379,6 +390,8 @@ let warning_options =
379390 Exact (" -Werror" ), Unit werror;
380391 Exact (" -Wall" ), Unit wall;
381392 Exact (" -w" ), Unit wnothing;
393+ _Regexp(" -Wno-.*$" ), Ignore ;
394+ _Regexp(" -W.*$" ), Self unknown_warning;
382395 longopt_int (" -fmax-errors" ) ((:= ) max_error);
383396 Exact (" -fno-diagnostics-show-option" ),Unset diagnostics_show_option;
384397 Exact (" -fdiagnostics-show-option" ),Set diagnostics_show_option;
@@ -425,9 +438,5 @@ let crash exn =
425438 exit 2
426439 end
427440
428- let no_loc = (" " , - 1 )
429-
430- let file_loc file = (file,- 10 )
431-
432441let active_warning ty =
433442 fst (classify_warning ty) <> SuppressedMsg
0 commit comments