Use {err,warn,info}_spec as subtypes of diag_spec ... ... to replace pretty much all uses of diag_spec in the initial part of the compilation process. The point of this is that up to about mode analysis, we use the presence or absence of errors of particular kinds to make decisions about whether or not to stop the compilation process. We do this to allow later stages to be able to omit having to handle missing information that earlier passes have already reported. compiler/error_spec.m: Add spec_severity_{err,warn,info} as subtypes of spec_severity. Use those to add {err,warn,info}_spec as subtypes of diag_spec. Rename the "diag_spec" function_symbol of the diag_spec type to "gen_spec". The old name is simply inappropriate for the new subtypes. Add versions of utility predicates that work on the new subtypes. Add a workaround for limitation of coerce operations. compiler/maybe_error.m: Make the maybeN types more strict by default by replacing one_or_more(diag_spec) as the argument type of the errorN function symbols with one_or_more(err_spec). This prevents bugs (of which this diff found some) where - a compiler component reports an error, but - the attached diag_specs contain no actual errors. Ruling out such bugs is a secondary objective of this diff. A bunch of places that report errors also report warnings. Provide mechanisms for attaching warnings both to errorN function symbols (in the presence of errors) and to okN function symbols (in their absence). Provide versions of existing operations that work on values of the new types. Delete existing operations for maybe[56] types where those operations were not used anywhere. compiler/error_util.m: compiler/write_error_spec.m: Add versions of utility predicates that work on the new subtypes. compiler/add_class.m: compiler/add_clause.m: compiler/add_foreign_enum.m: compiler/add_foreign_proc.m: compiler/add_mode.m: compiler/add_mutable_aux_preds.m: compiler/add_pragma_decl.m: compiler/add_pragma_gen.m: compiler/add_pragma_impl.m: compiler/add_pragma_tabling.m: compiler/add_pragma_type_spec.m: compiler/add_pragma_type_spec_constr.m: compiler/add_pred.m: compiler/add_type.m: compiler/check_field_access_functions.m: compiler/check_import_accessibility.m: compiler/check_libgrades.m: compiler/check_module_interface.m: compiler/check_options.m: compiler/check_promise.m: compiler/check_type_inst_mode_defns.m: compiler/check_typeclass.m: compiler/clause_to_proc.m: compiler/color_schemes.m: compiler/convert_import_use.m: compiler/convert_include.m: compiler/convert_parse_tree.m: compiler/d_file_deps.m: compiler/deps_map.m: compiler/du_type_layout.m: compiler/hlds_clauses.m: compiler/hlds_data.m: compiler/hlds_pred.m: compiler/instance_method_clauses.m: compiler/make_hlds_error.m: compiler/make_hlds_passes.m: compiler/make_hlds_warn.m: compiler/mercury_compile_args.m: compiler/mercury_compile_augment.m: compiler/mercury_compile_front_end.m: compiler/mercury_compile_main.m: compiler/mercury_compile_make_hlds.m: compiler/module_qual.mq_info.m: compiler/module_qual.qual_errors.m: compiler/module_qual.qualify_items.m: compiler/options_file.m: compiler/parse_class.m: compiler/parse_dcg_goal.m: compiler/parse_error.m: compiler/parse_goal.m: compiler/parse_goal_util.m: compiler/parse_inst_mode_defn.m: compiler/parse_module.m: compiler/parse_mutable.m: compiler/parse_pragma.m: compiler/parse_pragma_foreign.m: compiler/parse_pragma_tabling.m: compiler/parse_sym_name.m: compiler/parse_tree_out.m: compiler/parse_tree_out_clause.m: compiler/parse_type_defn.m: compiler/parse_type_name.m: compiler/parse_type_repn.m: compiler/parse_types.m: compiler/parse_util.m: compiler/parse_vars.m: compiler/prog_event.m: compiler/prog_foreign_enum.m: compiler/prog_item.m: compiler/prog_parse_tree.m: compiler/source_file_map.m: compiler/split_parse_tree_src.m: compiler/state_var.m: compiler/superhomogeneous.m: compiler/superhomogeneous_lambda.m: Return one (or more) of {err,warn,info}_specs instead of diag_specs. Perform the same replacements in data structures. (In most modules, diag_specs are replaced by *only* err_specs.) In modules where the diag_specs have all been replaced by the same subtype, keep using Specs as (part of) the names of the variables containing them. In modules that use more than one of the new subtypes, use ErrSpecs, WarnSpecs and/or InfoSpecs. Consistenly put err_specs before warn_specs, and both before info_specs. Change several predicates that used to take in,out pairs of list(diag_spec)s to return a single {err,warn}_spec, since this makes it easier to handle diagnostics of different severities separately. In a small handful of cases, replace code that created a diag_spec of dynamically-decided severity with two pieces of code that each create a diag_spec of a statically-decided severity, so that they can be added to different lists. compiler/add_pragma_util.m: As above, and also stop exporting two functions that are needed only in this module, and move them to the end of the module, after all their callers. compiler/grab_modules.m: As above, but record warnings as *warnings*, instead of as nonfatal errors, which is what we used to do. compiler/parse_item.m: As above, but change the behavior when parsing a promise yields no error but at least one warning. We use to print only the warnings, and then exit with a nonzero exit status, which is strange. So now, in such situations, also print a message about warnings in promises BEING errors themselves. compiler/accumulator.m: compiler/common.m: compiler/comp_unit_interface.m: compiler/cse_detection.m: compiler/decide_type_repn.m: compiler/det_check_proc.m: compiler/det_check_switch.m: compiler/det_infer_goal.m: compiler/equiv_type.m: compiler/equiv_type_parse_tree.m: compiler/error_sort.m: compiler/fact_table_gen.m: compiler/field_access.m: compiler/file_util.m: compiler/float_regs.m: compiler/get_dependencies.m: compiler/goal_expr_to_goal.m: compiler/handle_options.m: compiler/make.build.m: compiler/make.get_module_dep_info.m: compiler/make.library_install.m: compiler/make.module_target.m: compiler/make.program_target.m: compiler/make.top_level.m: compiler/make.track_flags.m: compiler/make_hlds_separate_items.m: compiler/mark_tail_calls.m: compiler/mark_trace_goals.m: compiler/mode_errors.m: compiler/mode_info.m: compiler/modes.m: compiler/module_baggage.m: compiler/module_qual.collect_mq_info.m: compiler/module_qual.id_set.m: compiler/old_type_constraints.m: compiler/opt_deps_spec.m: compiler/opt_format_call.m: compiler/pd_util.m: compiler/polymorphism_goal.m: compiler/post_typecheck.m: compiler/prog_mode.m: compiler/purity.m: compiler/qual_info.m: compiler/read_modules.m: compiler/recompilation.check.m: compiler/recompilation.used_file.m: compiler/simplify_goal.m: compiler/simplify_goal_call.m: compiler/stratify.m: compiler/style_checks.m: compiler/term_constr_errors.m: compiler/term_errors.m: compiler/typecheck.m: compiler/typecheck_error_arg_vector.m: compiler/typecheck_error_overload.m: compiler/typecheck_error_undef.m: compiler/typecheck_error_unify.m: compiler/typecheck_error_wrong_type.m: compiler/unused_imports.m: compiler/warn_unread_modules.m: compiler/write_deps_file.m: Conform to the changes above. tests/invalid_options_file/undefined_var.err_exp: Delete the initial "mmc:" from the expected output, since that is a prefix on message about errors, and the output of this test contains only warnings. With the diff to mercury_compile_args.m above, the compiler now recognizes this.