@@ -104,30 +104,45 @@ type warning_type =
104104 | Reduced_alignment
105105 | Non_linear_cond_expr
106106
107+ (* List of all warnings with default status.
108+ "true" means the warning is active by default.
109+ "false" means the warning is off by default. *)
110+ let all_warnings =
111+ [ (Unnamed , true );
112+ (Unknown_attribute , true );
113+ (Zero_length_array , false );
114+ (Celeven_extension , false );
115+ (Gnu_empty_struct , true );
116+ (Missing_declarations , true );
117+ (Constant_conversion , true );
118+ (Int_conversion , true );
119+ (Varargs , true );
120+ (Implicit_function_declaration , true );
121+ (Pointer_type_mismatch , true );
122+ (Compare_distinct_pointer_types , true );
123+ (Implicit_int , true );
124+ (Main_return_type , true );
125+ (Invalid_noreturn , true );
126+ (Return_type , true );
127+ (Literal_range , true );
128+ (Unknown_pragmas , false );
129+ (CompCert_conformance , false );
130+ (Inline_asm_sdump , true );
131+ (Unused_variable , false );
132+ (Unused_parameter , false );
133+ (Wrong_ais_parameter , true );
134+ (Ignored_attributes , true );
135+ (Extern_after_definition , true );
136+ (Static_in_inline , true );
137+ (Flexible_array_extensions , false );
138+ (Tentative_incomplete_static , false );
139+ (Reduced_alignment , false );
140+ (Non_linear_cond_expr , false );
141+ ]
142+
107143(* List of active warnings *)
108- let active_warnings: warning_type list ref = ref [
109- Unnamed ;
110- Unknown_attribute ;
111- Gnu_empty_struct ;
112- Missing_declarations ;
113- Constant_conversion ;
114- Int_conversion ;
115- Varargs ;
116- Implicit_function_declaration ;
117- Pointer_type_mismatch ;
118- Compare_distinct_pointer_types ;
119- Implicit_int ;
120- Main_return_type ;
121- Invalid_noreturn ;
122- Return_type ;
123- Literal_range ;
124- Inline_asm_sdump ;
125- Wrong_ais_parameter ;
126- Unused_ais_parameter ;
127- Ignored_attributes ;
128- Extern_after_definition ;
129- Static_in_inline ;
130- ]
144+ let active_warnings: warning_type list ref =
145+ ref (List. map fst (List. filter snd all_warnings))
131146
132147(* List of errors treated as warning *)
133148let error_warnings: warning_type list ref = ref []
@@ -188,76 +203,14 @@ let warning_not_as_error w () =
188203
189204(* Activate all warnings *)
190205let wall () =
191- active_warnings:= [
192- Unnamed ;
193- Unknown_attribute ;
194- Zero_length_array ;
195- Celeven_extension ;
196- Gnu_empty_struct ;
197- Missing_declarations ;
198- Constant_conversion ;
199- Int_conversion ;
200- Varargs ;
201- Implicit_function_declaration ;
202- Pointer_type_mismatch ;
203- Compare_distinct_pointer_types ;
204- Implicit_int ;
205- Main_return_type ;
206- Invalid_noreturn ;
207- Return_type ;
208- Literal_range ;
209- Unknown_pragmas ;
210- CompCert_conformance ;
211- Inline_asm_sdump ;
212- Unused_variable ;
213- Unused_parameter ;
214- Wrong_ais_parameter ;
215- Ignored_attributes ;
216- Extern_after_definition ;
217- Static_in_inline ;
218- Flexible_array_extensions ;
219- Tentative_incomplete_static ;
220- Reduced_alignment ;
221- Non_linear_cond_expr ;
222- ]
206+ active_warnings:= List. map fst all_warnings
223207
224208let wnothing () =
225209 active_warnings := []
226210
227211(* Make all warnings an error *)
228212let werror () =
229- error_warnings:= [
230- Unnamed ;
231- Unknown_attribute ;
232- Zero_length_array ;
233- Celeven_extension ;
234- Gnu_empty_struct ;
235- Missing_declarations ;
236- Constant_conversion ;
237- Int_conversion ;
238- Varargs ;
239- Implicit_function_declaration ;
240- Pointer_type_mismatch ;
241- Compare_distinct_pointer_types ;
242- Implicit_int ;
243- Main_return_type ;
244- Invalid_noreturn ;
245- Return_type ;
246- Literal_range ;
247- Unknown_pragmas ;
248- CompCert_conformance ;
249- Inline_asm_sdump ;
250- Unused_variable ;
251- Wrong_ais_parameter ;
252- Unused_ais_parameter ;
253- Ignored_attributes ;
254- Extern_after_definition ;
255- Static_in_inline ;
256- Flexible_array_extensions ;
257- Tentative_incomplete_static ;
258- Reduced_alignment ;
259- Non_linear_cond_expr ;
260- ]
213+ error_warnings:= List. map fst all_warnings
261214
262215(* Generate the warning key for the message *)
263216let key_of_warning w =
@@ -411,37 +364,7 @@ let error_option w =
411364 Exact (" -Wno-error=" ^ key), Unit ( warning_not_as_error w)]
412365
413366let warning_options =
414- error_option Unnamed @
415- error_option Unknown_attribute @
416- error_option Zero_length_array @
417- error_option Celeven_extension @
418- error_option Gnu_empty_struct @
419- error_option Missing_declarations @
420- error_option Constant_conversion @
421- error_option Int_conversion @
422- error_option Varargs @
423- error_option Implicit_function_declaration @
424- error_option Pointer_type_mismatch @
425- error_option Compare_distinct_pointer_types @
426- error_option Implicit_int @
427- error_option Main_return_type @
428- error_option Invalid_noreturn @
429- error_option Return_type @
430- error_option Literal_range @
431- error_option Unknown_pragmas @
432- error_option CompCert_conformance @
433- error_option Inline_asm_sdump @
434- error_option Unused_variable @
435- error_option Unused_parameter @
436- error_option Wrong_ais_parameter @
437- error_option Unused_ais_parameter @
438- error_option Ignored_attributes @
439- error_option Extern_after_definition @
440- error_option Static_in_inline @
441- error_option Flexible_array_extensions @
442- error_option Tentative_incomplete_static @
443- error_option Reduced_alignment @
444- error_option Non_linear_cond_expr @
367+ List. concat (List. map (fun (w , active ) -> error_option w) all_warnings) @
445368 [Exact (" -Wfatal-errors" ), Set error_fatal;
446369 Exact (" -fdiagnostics-color" ), Ignore ; (* Either output supports it or no color *)
447370 Exact (" -fno-diagnostics-color" ), Unset color_diagnostics;
0 commit comments