mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-05-01 01:04:43 +00:00
The objective of this step is two-fold:
- to fix --inhibit-warnings, making it shut up all warning
and informational messages; and
- to ensure that it *stays* fixed, even when after new diagnostics
are added.
As part of this fix, this diff adds a whole bunch of new warning
options, in order to control the warnings that previously were
not controlled by any option. (There was no need for new
informational options.)
As it happens, we have long used severity_informational for messages
that did not report any information about the code being compiled,
but to report actions that the compiler was taking. Create a new
option category, oc_report, for the new options that now control
those diagnostics.
---------------------
compiler/error_spec.m:
Change severity_warning and severity_informational to take an option
as as argument. The semantics is that the diagnostic in which
the severity occurs is conditional on that option, meaning that
it is printed only if that option is set to "yes".
Delete the severity_conditional function symbol from the severity
type, since the mechanism just above handles its only use case.
Define subtypes to represent error_specs in a standard form.
compiler/error_sort.m:
Provide operations to convert error specs into their standard form.
Make the sorting operation itself operate on the standard form.
compiler/write_error_spec.m:
Convert error_specs to standard form before writing them out,
in order to avoid duplicating the code for their standardization.
Change the code that writes out error_specs to operate on the
standard form. Implement the test implicit in the warning and
and informational severities in this code.
compiler/error_util.m:
compiler/compiler_util.m:
Delete operations that do not make sense with the new severity type.
---------------------
compiler/options.m:
Add new options to control all the previously-uncontrolled
warning and informational messages.
NEWS.md:
Announce the *public* new options.
compiler/option_categories.m:
compiler/print_help.m:
Add the new option category, and fake-include it in the help text
and the user guide. (The inclusion is fake because none of the
options in the new category are user visible, meaning the section
containing them is not visible either.)
---------------------
compiler/det_infer_goal.m:
Start a severity warning diagnostic with "Warning:"
instead of "Error:".
compiler/mark_trace_goals.m:
Fix an incorrect error message.
compiler/purity.m:
Replace a correct/incorrect color pair with two inconsistent colors,
because there is a reasonable probability of each one being right.
---------------------
compiler/accumulator.m:
compiler/add_clause.m:
compiler/add_mode.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/check_module_interface.m:
compiler/check_type_inst_mode_defns.m:
compiler/check_typeclass.m:
compiler/color_schemes.m:
compiler/common.m:
compiler/convert_import_use.m:
compiler/convert_parse_tree.m:
compiler/dead_proc_elim.m:
compiler/det_check_proc.m:
compiler/det_check_switch.m:
compiler/det_infer_goal.m:
compiler/du_type_layout.m:
compiler/format_call_errors.m:
compiler/grab_modules.m:
compiler/hlds_call_tree.m:
compiler/inst_check.m:
compiler/introduce_parallelism.m:
compiler/make_hlds_error.m:
compiler/make_hlds_warn.m:
compiler/mark_tail_calls.m:
compiler/mark_trace_goals.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/modes.m:
compiler/module_qual.qual_errors.m:
compiler/opt_deps_spec.m:
compiler/options_file.m:
compiler/parse_goal.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/pre_typecheck.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/simplify_goal.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_disj.m:
compiler/simplify_goal_ite.m:
compiler/split_parse_tree_src.m:
compiler/state_var.m:
compiler/stratify.m:
compiler/style_checks.m:
compiler/superhomogeneous.m:
compiler/table_gen.m:
compiler/term_constr_errors.m:
compiler/term_errors.m:
compiler/termination.m:
compiler/typecheck_clauses.m:
compiler/typecheck_error_overload.m:
compiler/typecheck_error_undef.m:
compiler/typecheck_errors.m:
compiler/typecheck_msgs.m:
compiler/unused_args.m:
compiler/unused_imports.m:
compiler/warn_unread_modules.m:
compiler/write_module_interface_files.m:
Conform to the changes above, mostly by either
- adding an option to all warning and informational messages,
sometimes using existing warning options and sometimes new ones,
or
- turning already explicitly-conditional-on-an-option messages
into implicitly-conditional-on-that-option messages.
---------------------
tests/invalid/one_member.m:
Conform to the change in det_infer_goal.m.
tests/invalid/require_tailrec_1.err_exp:
tests/invalid/require_tailrec_2.err_exp:
Actually obey the options for these modules in Mercury.options.
tests/invalid_purity/purity.err_exp:
tests/warnings/purity_warnings.err_exp:
Conform to the change in purity.m.
tests/warnings/moved_trace_goal.err_exp:
Conform to the change in mark_trace_goals.m.
tests/warnings/help_text.err_exp:
Expect the documentation of all the new options.
290 lines
11 KiB
Mathematica
290 lines
11 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 2025 The Mercury team.
|
|
% This file may only be copied under the terms of the GNU General
|
|
% Public License - see the file COPYING in the Mercury distribution.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: options_categories.m.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module libs.option_categories.
|
|
:- interface.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- type option_category
|
|
---> oc_help
|
|
% Options that call for the output of help text.
|
|
; oc_cmdline
|
|
% Options that manipulate the command line itself.
|
|
; oc_opmode
|
|
% Options that are used only to select an invocation's op_mode.
|
|
; oc_grade_gen
|
|
; oc_grade_target
|
|
; oc_grade_llds
|
|
; oc_grade_mlds
|
|
; oc_grade_mdb
|
|
; oc_grade_ssdb
|
|
; oc_grade_mprof
|
|
; oc_grade_mdprof
|
|
; oc_grade_clprof
|
|
; oc_grade_tsprof
|
|
; oc_grade_etc
|
|
; oc_grade_dev
|
|
% Options that affect binary compatibility.
|
|
% This category should subdivided into separate subcategories
|
|
% for mdb, ssd, mprof, mdprof etc, but only after moving
|
|
% the non-grade options out of the category altogether.
|
|
; oc_infer
|
|
% Options that tell the compiler what to infer.
|
|
; oc_semantics
|
|
% Options that specify which semantics variant to use.
|
|
; oc_verbosity
|
|
% Options that users can use to control how many progress updates
|
|
% they want the compiler to give them.
|
|
; oc_diag_gen
|
|
% Options for controlling diagnostics generally.
|
|
% One class tells the compiler either under what circumstances
|
|
% it should generate diagnostic output; another class specifies
|
|
% how diagnostic output should be presented.
|
|
; oc_diag_color
|
|
% Options for controlling color in diagnostics.
|
|
; oc_diag_int
|
|
% Internal-use-only options for controlling diagnostics.
|
|
; oc_warn_dodgy_mod
|
|
; oc_warn_dodgy_pred
|
|
; oc_warn_dodgy_prg
|
|
; oc_warn_dodgy_goal
|
|
; oc_warn_dodgy_inst
|
|
; oc_warn_file
|
|
% Warnings about code that is possibly incorrect.
|
|
; oc_warn_perf
|
|
; oc_warn_perf_c
|
|
% Warnings about code that probably could be faster.
|
|
; oc_warn_style_mod
|
|
; oc_warn_style_pred
|
|
; oc_warn_style_goal
|
|
; oc_warn_style_goal_c
|
|
; oc_warn_style_order
|
|
; oc_warn_style_ctg
|
|
; oc_warn_style_ctg_c
|
|
% Warnings about programming style.
|
|
; oc_warn_ctrl
|
|
% Options that *control* warnings.
|
|
% XXX Split into subparts, one for each of oc_warn_*
|
|
% that some now-oc_warn_ctrl option controls.
|
|
% This should enable us to put the documentation of e.g.
|
|
% inform_incomplete_switch_threshold, immediately after
|
|
% the documentation of inform_incomplete_switch.
|
|
; oc_warn_halt
|
|
% Options that specify when warnings should treated as errors.
|
|
; oc_inform
|
|
% Requests for information.
|
|
; oc_file_req
|
|
% Options that request the compiler to generate files
|
|
% containing information derived from the module being compiled.
|
|
; oc_report
|
|
% Options that control whether some compiler reports are printed.
|
|
; oc_tracegoal
|
|
% Options that control trace goals.
|
|
; oc_mdb
|
|
% Options that control how the compiler prepares for mdb debugging.
|
|
; oc_mdb_dev
|
|
% Developer-only options about mdb debugging.
|
|
% XXX Some of these may be internal-use-only, not intended
|
|
% even for developers.
|
|
; oc_ssdb
|
|
; oc_ssdb_dev
|
|
% Options that control how the compiler prepares for ssdb.
|
|
; oc_mdprof
|
|
% Options that control deep profiling.
|
|
; oc_opt_ctrl
|
|
% Options that control optimization levels.
|
|
; oc_opt_hh
|
|
; oc_opt_hh_exp
|
|
% HLDS->HLDS optimizations. The _exp suffix indicates that
|
|
% the optimization is experimental.
|
|
; oc_opt_hlm
|
|
% HLDS->{LLDS,MLDS} optimizations.
|
|
; oc_opt_mm
|
|
% MLDS->MLDS optimizations.
|
|
; oc_opt_hm
|
|
% HLDS->MLDS optimizations.
|
|
; oc_opt_hl
|
|
% HLDS->LLDS optimizations.
|
|
; oc_opt_ll
|
|
% LLDS->LLDS optimizations.
|
|
; oc_opt_lc
|
|
% LLDS-> C optimizations. (There are no MLDS->C optimizations.)
|
|
; oc_plain_opt
|
|
; oc_trans_opt
|
|
; oc_latex_opt
|
|
% Options that control the operation of intermodule optimization.
|
|
; oc_pm_term1
|
|
; oc_pm_term2
|
|
; oc_pm_misc
|
|
% Options for user control of program analyses.
|
|
; oc_output_mod
|
|
% Options that ask the compiler to modify some aspect
|
|
% of the generated target code.
|
|
; oc_output_dev
|
|
% Developer-only options that ask the compiler to modify
|
|
% some aspect of the generated target code.
|
|
; oc_make
|
|
% Options controlling mmc --make.
|
|
; oc_target_comp
|
|
; oc_target_c
|
|
; oc_target_java
|
|
; oc_target_csharp
|
|
% Options that control how the target language files we generate
|
|
% are further compiled.
|
|
% Subdivided for C, Java and C#.
|
|
; oc_link_c_cs_j
|
|
; oc_link_c_cs
|
|
; oc_link_c
|
|
; oc_link_java
|
|
; oc_link_csharp
|
|
% Options that control how executables, or their equivalents
|
|
% for some target languages, are generated.
|
|
% Subdivided for C, Java and C#, and for the combinations
|
|
% that actually apply to some option.
|
|
; oc_search
|
|
% XXX Document me.
|
|
; oc_buildsys
|
|
% XXX Document me.
|
|
% XXX We should separate search path options (the majority)
|
|
% from everything else.
|
|
; oc_env
|
|
% Options that tell the compiler something about the environment,
|
|
% or platform, on which it is operating.
|
|
; oc_config
|
|
% The results of autoconfiguration, or of executing
|
|
% tools/configure_cross.
|
|
; oc_mconfig
|
|
% Options which are reserved for use by the Mercury.config file.
|
|
; oc_dev_ctrl
|
|
% Options developers can use to control what the compiler does.
|
|
; oc_dev_verb
|
|
% Developer-only kinds of verbosity options.
|
|
; oc_dev_debug
|
|
% Options developers can use to debug compiler components.
|
|
; oc_dev_dump
|
|
% Options to control dumps of internal code representations.
|
|
; oc_internal
|
|
% Options for internal (and developer) use only.
|
|
; oc_unused.
|
|
% options that are now unused, and which are kept around
|
|
% only for backward compatibility.
|
|
% XXX Is this a good idea? If users want the effect of an
|
|
% old option, then deleting the option and breaking their code
|
|
% is less likely to mislead than keeping the option as a noop.
|
|
|
|
% The job of this predicate is to provide an authoritative list
|
|
% of all the option_categories for print_help.m. This is done by
|
|
% calling solutions on the second mode.
|
|
%
|
|
% The first mode is unused; it is there only to ensure completeness.
|
|
%
|
|
% The int output is a never-used argument.
|
|
%
|
|
:- pred option_categories(option_category, int).
|
|
:- mode option_categories(in, out) is det.
|
|
:- mode option_categories(out, out) is multi.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
option_categories(oc_help, 0).
|
|
option_categories(oc_cmdline, 0).
|
|
option_categories(oc_opmode, 0).
|
|
option_categories(oc_grade_gen, 0).
|
|
option_categories(oc_grade_target, 0).
|
|
option_categories(oc_grade_llds, 0).
|
|
option_categories(oc_grade_mlds, 0).
|
|
option_categories(oc_grade_mdb, 0).
|
|
option_categories(oc_grade_ssdb, 0).
|
|
option_categories(oc_grade_mprof, 0).
|
|
option_categories(oc_grade_mdprof, 0).
|
|
option_categories(oc_grade_clprof, 0).
|
|
option_categories(oc_grade_tsprof, 0).
|
|
option_categories(oc_grade_etc, 0).
|
|
option_categories(oc_grade_dev, 0).
|
|
option_categories(oc_infer, 0).
|
|
option_categories(oc_semantics, 0).
|
|
option_categories(oc_verbosity, 0).
|
|
option_categories(oc_diag_gen, 0).
|
|
option_categories(oc_diag_color, 0).
|
|
option_categories(oc_diag_int, 0).
|
|
option_categories(oc_warn_dodgy_mod, 0).
|
|
option_categories(oc_warn_dodgy_pred, 0).
|
|
option_categories(oc_warn_dodgy_prg, 0).
|
|
option_categories(oc_warn_dodgy_goal, 0).
|
|
option_categories(oc_warn_dodgy_inst, 0).
|
|
option_categories(oc_warn_file, 0).
|
|
option_categories(oc_warn_perf, 0).
|
|
option_categories(oc_warn_perf_c, 0).
|
|
option_categories(oc_warn_style_mod, 0).
|
|
option_categories(oc_warn_style_pred, 0).
|
|
option_categories(oc_warn_style_order, 0).
|
|
option_categories(oc_warn_style_ctg, 0).
|
|
option_categories(oc_warn_style_ctg_c, 0).
|
|
option_categories(oc_warn_style_goal, 0).
|
|
option_categories(oc_warn_style_goal_c, 0).
|
|
option_categories(oc_warn_ctrl, 0).
|
|
option_categories(oc_warn_halt, 0).
|
|
option_categories(oc_inform, 0).
|
|
option_categories(oc_file_req, 0).
|
|
option_categories(oc_report, 0).
|
|
option_categories(oc_tracegoal, 0).
|
|
option_categories(oc_mdb, 0).
|
|
option_categories(oc_mdb_dev, 0).
|
|
option_categories(oc_ssdb, 0).
|
|
option_categories(oc_ssdb_dev, 0).
|
|
option_categories(oc_mdprof, 0).
|
|
option_categories(oc_opt_ctrl, 0).
|
|
option_categories(oc_opt_hh, 0).
|
|
option_categories(oc_opt_hh_exp, 0).
|
|
option_categories(oc_opt_hlm, 0).
|
|
option_categories(oc_opt_mm, 0).
|
|
option_categories(oc_opt_hm, 0).
|
|
option_categories(oc_opt_hl, 0).
|
|
option_categories(oc_opt_ll, 0).
|
|
option_categories(oc_opt_lc, 0).
|
|
option_categories(oc_plain_opt, 0).
|
|
option_categories(oc_trans_opt, 0).
|
|
option_categories(oc_latex_opt, 0).
|
|
option_categories(oc_pm_term1, 0).
|
|
option_categories(oc_pm_term2, 0).
|
|
option_categories(oc_pm_misc, 0).
|
|
option_categories(oc_output_mod, 0).
|
|
option_categories(oc_output_dev, 0).
|
|
option_categories(oc_make, 0).
|
|
option_categories(oc_target_comp, 0).
|
|
option_categories(oc_target_c, 0).
|
|
option_categories(oc_target_java, 0).
|
|
option_categories(oc_target_csharp, 0).
|
|
option_categories(oc_link_c_cs_j, 0).
|
|
option_categories(oc_link_c_cs, 0).
|
|
option_categories(oc_link_c, 0).
|
|
option_categories(oc_link_java, 0).
|
|
option_categories(oc_link_csharp, 0).
|
|
option_categories(oc_search, 0).
|
|
option_categories(oc_buildsys, 0).
|
|
option_categories(oc_env, 0).
|
|
option_categories(oc_config, 0).
|
|
option_categories(oc_mconfig, 0).
|
|
option_categories(oc_dev_ctrl, 0).
|
|
option_categories(oc_dev_verb, 0).
|
|
option_categories(oc_dev_debug, 0).
|
|
option_categories(oc_dev_dump, 0).
|
|
option_categories(oc_internal, 0).
|
|
option_categories(oc_unused, 0).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
:- end_module libs.option_categories.
|
|
%---------------------------------------------------------------------------%
|