mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 03:13:40 +00:00
de8f79cac3272dbabddd2e072b94de54612276bc
14 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
823de2d37b |
Require warning/info messages to specify an option.
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.
|
||
|
|
79bfb1247f |
Carve prog_parse_tree.m out of prog_item.m.
compiler/prog_item.m:
compiler/prog_parse_tree.m:
Split prog_item.m into two modules, with the new module prog_parse_tree.m
containing the definitions of the file-kind-specific parse trees,
and prog_item.m continuing to contain the definitions of the items
that occur in those parse trees. Specialize the top-of-module comment
to the current contents of each module.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new module.
compiler/*.m:
Conform to the changes above.
|
||
|
|
2a08f3bf23 |
Use color in parse_class.m and check_module_interface.m.
compiler/check_module_interface.m:
compiler/parse_class.m:
Add color to the diagnostics generated by these modules.
In a few cases, improve the wording of the diagnostic.
tests/invalid/type_inf_loop.err_exp:
tests/invalid/typeclass_missing_det_3.err_exp:
tests/invalid_make_int/bad_existential_data_type.int_err_exp:
tests/invalid_make_int/unbound_type_vars_int.int_err_exp:
tests/invalid_nodepend/bigtest.err_exp:
tests/invalid_nodepend/duplicate_modes.err_exp:
tests/invalid_nodepend/errors_1.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_nodepend/errors_3.err_exp:
tests/invalid_nodepend/funcs_as_preds.err_exp:
tests/invalid_nodepend/inst_list_dup.err_exp:
tests/invalid_nodepend/no_exports.err_exp:
tests/invalid_nodepend/occurs.err_exp:
tests/invalid_nodepend/prog_io_erroneous.err_exp:
tests/invalid_nodepend/typeclass_no_param.err_exp:
tests/invalid_nodepend/typeclass_test_1.err_exp:
tests/invalid_nodepend/typeclass_test_2.err_exp:
tests/invalid_nodepend/typeclass_test_3.err_exp:
tests/invalid_nodepend/unicode_1.err_exp:
tests/invalid_nodepend/unicode_2.err_exp:
tests/invalid_nodepend/var_as_pred_name.err_exp:
tests/invalid_nodepend/vars_in_wrong_places.err_exp:
tests/warnings/empty_interface.err_exp:
Expect updated diagnostics.
|
||
|
|
dc12878708 |
Shorten function symbols in error_specs.
compiler/error_spec.m:
Replace simplest_spec with spec, and simplest_no_context_spec with
no_ctxt_spec. These are now the most frequently used function symbols
to create error specs, so their name should not make them out to be
the exception.
Replace simplest_msg with msg, and simplest_no_context_msg with
no_ctxt_msg for the same reason.
Abbreviate some of the long phase names.
compiler/*.m:
Conform to the changes above. Most of these changes were done by a script,
with minor manual tidying up, which consisted mostly of fitting code
constructing error specs onto fewer lines than before.
|
||
|
|
5f0600709e |
Fix and update copyright notices.
compiler/check_module_interface.m:
compiler/make.check_up_to_date.m:
As above.
|
||
|
|
24db5cd895 |
Split higher_order.m into four submodules.
This diff only moves code around. There are no algorithmic changes,
apart from the change to check_module_interface.m.
compiler/higher_order.m:
Replace all the code in this module with include_module declarations
for the following four new submodules, which together contain its
previous contents.
compiler/higher_order.specialize_in_module.m:
The top level part of the old higher_order.m.
compiler/higher_order.specialize_calls.m:
The part of the old higher_order.m that mostly scans procedure bodies
looking for operations (usually calls) to optimize.
compiler/higher_order.make_specialized_preds.m:
The part of the old higher_order.m that mostly constructs the definitions
of the specialized predicates and functions.
The above "mostly"s are there because the lines of responsibility in the
existing code are neither all that clear, nor are they documented. :-(
compiler/higher_order.higher_order_global_info.m:
The part of the old higher_order.m that defines the data structures
shared by the above three modules, as well as some operations
on (parts of) those data structures that are needed in more than one
of the modules above.
compiler/Mercury.options:
Disable a warning we would get for the new higher_order.m, which contains
just a single import_module declaration in its interface.
compiler/check_module_interface.m:
Change the test for the "this module exports nothing" warning, so that
future compiler versions won't generate a warning for module that
includes more than one submodule, even if only one is exported.
compiler/options.m:
Provide a way to check for the presence of the change to
check_module_interface.m in the installed compiler.
compiler/mercury_compile_middle_passes.m:
Conform to the changes above.
compiler/notes/compiler_design.html:
Document the new modules.
|
||
|
|
25f8a6cc99 |
Add new option --generate-dependencies-ints.
This new option extends --generate-dependencies to take advantage of the
opportunity afforded by the fact that "mmc --generate-dependencies prog.m"
reads in every Mercury source file in the current directory that is
part of "prog". It does this by
- generating the .int3 file of all local-directory modules of the program;
- generating the .int0 file for each these modules that has submodules;
- generating the .int and .int2 files of all local-directory modules
of the program.
Normally, the process of creating .int0, .int and .int3 files would
need to read in .int0 and .int3 files, but in every one of these cases,
we have just written out those files, so simply holding onto their
parse trees, we can skip this step. On my laptop, on a directory
containing library/*.m, mdbcomp/*.m and compiler/*.m, generating
the dependencies and generating all the .int3/.int0/.int/.int2 files
takes just over 25 seconds. Using the new option, the same process
takes less than 10 seconds.
compiler/options.m:
Add the new option.
compiler/op_mode.m:
Add a new variant of the existing op_mode for --generate-dependencies,
which we select in the presence of the new option.
compiler/mercury_compile_main.m:
Implement the new op_mode.
Fix an old issue, which is that "mmc --make-private-interface x.m"
generated a .int0 file for *every* module in x.m, even the modules
that don't have any submodules.
compiler/deps_map.m:
The code implementing the new option needs to know which modules
of the program are in the current directory. The deps_map structure
built by the code shared with the implementation of --generate-dependencies
has not needed that info until now, so add a new field to the deps
structure of each module to provide this info.
compiler/generate_dep_d_files.m:
Return the deps_map created by the code that implements both
--generate-dependencies and the new option to mercury_compile_main.m.
compiler/write_module_interface_files.m:
Add a flag to the predicates that first construct the parse trees of,
and then write out, .int3/.int0/.int/.int2 files, that
mercury_compile_main.m can use to tell them to record the parse trees
in the have read module maps.
Add new variants of two of those predicates that take some of their
arguments from burdened_module structures, since that is the form
in which mercury_compile_main.m has that info.
compiler/module_baggage.m:
The predicates in write_module_interface_files.m that generate
.int0/.int/.int2 files take an argument that should be the timestamp
of the source file they are being derived from, if that timestamp
is needed for smart recompilation. Until now, we only ever invoked
those predicates when we have just read in the source file,
and this timestamp was readily available. The code implementing
the new option needs to store this info for a short time, and
the module baggage is the obvious place to store it, so add this field
to the baggage.
compiler/error_spec.m:
An invocation of the compiler with new option may report errors that
prevent the construction of interface files for several modules.
The new code in mercury_compile.m prints the error_specs that have
contexts in the order of those contexts, but we want to print
the messages without contexts (which in this case report that
certain files could not be written or copied) to have a useful
order too. Make this possible by allowing the invisible pieces
we use for ordering to specify that order via a string (in this case,
the name of the file that e.g. could not be written), rather than
the only previous option, an integer.
compiler/grab_modules.m:
compiler/make.get_module_dep_info.m:
compiler/make.module_dep_file.m:
Fill in the new field in the module baggage.
compiler/check_module_interface.m:
compiler/handle_options.m:
compiler/make_hlds_error.m:
compiler/parse_module.m:
compiler/prog_foreign_enum.m:
compiler/typecheck_error_util.m:
compiler/typecheck_msgs.m:
compiler/write_deps_file.m:
compiler/write_error_spec.m:
Conform to the changes above.
|
||
|
|
9d38b252bf |
Separate marker pragmas from other decl/impl pragmas.
compiler/prog_item.m:
Previously, both decl and impl pragmas contained some pragma kinds
that contained only the specification of a predicate or function.
These served only to specify a marker to be applied to the named
predicate or function.
This diff separates out those kinds of pragmas from the types of
both the decl pragmas and the impl pragmas (the difference is that
decl pragmas may appear in module interfaces, while impl pragmas may not),
and gives them two new representations: decl markers and impl markers.
While in the old representation, each kind of marker had its own wrapper
around the predicate/function specification, in the new representation,
they are side-by-side, which allows simpler construction techniques
and smaller code.
Update the definition of parse_tree_module_src, parse_tree_plain_opt,
parse_tree_int0 and parse_tree_int1 to include markers alongside
pragmas of each kind. Use subtypes to restrict the kinds of markers
that can appear in parse_tree_plain_opts to the set that we actually
can put into them. (Source files of course can contain any markers,
and .intN files either get put into them either all of the markers
that occur in the source file in a given section, or none of them.)
Delete the item_pragma_info type, which was a wrapper around
the specific info of each pragma, and stored a context and an item
sequence number alongside it. Move the context and the item sequence
number into the representation of each pragma. This should reduce
visual clutter in the source code at places that construct or deconstruct
pragmas, and at runtime (with direct args) it should reduce both
the number of memory cells we need to allocate, and the number
of pointers we need to follow.
Include decl vs impl in the names of some function symbols.
Partly to counteract that, shorten some names to avoid excessive
line lengths.
compiler/add_pragma.m:
Add predicates to add decl and impl markers.
Move the predicates looping over lists of pragma next to the
predicates handling those pragmas.
compiler/make_hlds_passes.m:
Add both decl and impl markers before adding foreign_procs.
The ability to do this was the original motivation for this diff.
Update the comments both about this issue, and about why we delay
adding tabling pragmas to the HLDS.
compiler/check_module_interface.m:
Conform to the changes above.
Add an XXX about something fishy.
compiler/item_util.m:
Delete aux functions that are no longer needed.
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pragma_type_spec.m:
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/hlds_module.m:
compiler/intermod.m:
compiler/intermod_analysis.m:
compiler/make_hlds_separate_items.m:
compiler/mercury_compile_middle_passes.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qual_errors.m:
compiler/module_qual.qualify_items.m:
compiler/parse_pragma.m:
compiler/parse_pragma_analysis.m:
compiler/parse_pragma_foreign.m:
compiler/parse_pragma_tabling.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/prog_mutable.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/unused_args.m:
Conform to the changes above.
|
||
|
|
155bc71d72 |
Make foreign_procs their own top-level item kind.
compiler/prog_item.m:
Change foreign_procs from being one kind of impl_pragma item
to being their own item kind. Because of this, the changes to
some of the modules listed below delete "pragma" from the names
of predicates and types referring to foreign_procs.
Include foreign_proc items in parse_tree_module_srcs and
parse_tree_plain_opts, the two kinds of parse trees that may contain
foreign_procs.
compiler/make_hlds_separate_items.m:
Gather foreign procs independently of impl pragmas.
compiler/make_hlds_passes.m:
Add foreign_procs from the parse_tree_module_src and any
parse_tree_plain_opts to the HLDS at the same time as we add
foreign_procs generated by the compiler to implement solver types
and mutables. Document the reason for this.
Document also the reason why we should add all marker pragmas
just before we do this. Document the reason why two tests will fail
until that, or something similar, is done.
compiler/add_foreign_proc.m:
Delete a test that was required only because we couldn't guarantee
the relative order of adding foreign_procs and pragmas that mark
predicates as external on one backend.
compiler/module_qual.qual_errors.m:
Add foreign_procs as a possible context for errors during qualification.
compiler/status.m:
Add a comment documented an old issue.
compiler/add_mutable_aux_preds.m:
compiler/add_pragma.m:
compiler/add_pragma_tabling.m:
compiler/add_solver.m:
compiler/check_module_interface.m:
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
compiler/coverage_profiling.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/equiv_type.m:
compiler/foreign.m:
compiler/get_dependencies.m:
compiler/goal_util.m:
compiler/grab_modules.m:
compiler/hlds_goal.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/ml_foreign_proc_gen.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_pragma_foreign.m:
compiler/parse_tree_out.m:
compiler/parse_tree_out_pragma.m:
compiler/pragma_c_gen.m:
compiler/prog_item_stats.m:
compiler/prog_mutable.m:
compiler/recompilation.version.m:
compiler/structure_sharing.domain.m:
compiler/table_gen.m:
compiler/tabling_analysis.m:
compiler/term_util.m:
compiler/termination.m:
compiler/trailing_analysis.m:
compiler/prog_data_foreign.m:
compiler/unify_proc.m:
Conform to the changes above.
|
||
|
|
fcad1b21e8 |
Delete module_names_contexts fields from parse trees.
compiler/prog_item.m:
We used to include information about include_module, import_module
and use_module declarations in a module in the parse_tree_module_src
in two forms: an unchecked form, which had type module_names_contexts,
and a checked form, which had types include_module_map and
import_and_or_use_map respectively. We have been gradually switching
more and more code working on parse trees from taking the unchecked form
as input to taking the checked form as input.
This diff completes the process.
- It deletes the ptms_{int,imp}_includes and ptms_{int,imp}{imports,uses}
fields from parse_tree_module_src. Their checked versions remain.
- It changes the parse_tree_int3 type to store include and import
information using checked rather than unchecked types. The reason
why this wasn't done before is that the checked data structures
could not preserve the relevant invariants until subtypes were added
to the language. This diff thus also defines the needed new subtype.
Fix a typo (wrong int file number) in a field name.
compiler/item_util.m:
Add some utility predicates needed by new code in the modules below.
Change the interface of a utility predicate
- to stop requiring the caller to supply unchecked data structures,
constructing them internally as intermediate data structures instead,
and
- to stop returning some now-unneeded unchecked data structures.
Keep some utility predicates private that are no longer needed
outside this module.
Delete a whole bunch of utility predicates which are no longer needed
at all.
compiler/comp_unit_interface.m:
compiler/convert_parse_tree.m:
Conform to the changes in prog_item.m, by changing code that used
to construct unchecked to now construct checked data structures.
compiler/check_module_interface.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/grab_modules.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.collect_mq_info.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out.m:
compiler/write_deps_file.m:
Conform to the changes in prog_item.m, mostly by changing code that
used to take unchecked data structures as input to now take checked
data structures as input.
compiler/deps_map.m:
compiler/module_baggage.m:
compiler/module_dep_info.m:
Delete now-unneeded imports.
|
||
|
|
307b1dc148 |
Split up error_util.m into five modules.
compiler/error_spec.m:
This new module contains the part of the old error_util.m that defines
the error_spec type, and some functions that can help construct pieces
of error_specs. Most modules of the compiler that deal with errors
will need to import only this part of the old error_util.m.
This change also renames the format_component type to format_piece,
which matches our long-standing naming convention for variables containing
(lists of) values of this type.
compiler/write_error_spec.m:
This new module contains the part of the old error_util.m that
writes out error specs, and converts them to strings.
This diff marks as obsolete the versions of predicates that
write out error specs to the current output stream, without
*explicitly* specifying the intended stream.
compiler/error_sort.m:
This new module contains the part of the old error_util.m that
sorts lists of error specs and error msgs.
compiler/error_type_util.m:
This new module contains the part of the old error_util.m that
convert types to format_pieces that generate readable output.
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Include and document the new modules.
compiler/error_util.m:
The code remaining in the original error_util.m consists of
general utility predicates and functions that don't fit into
any of the modules above.
Delete an unneeded pair of I/O states from the argument list
of a predicate.
compiler/file_util.m:
Move the unable_to_open_file predicate here from error_util.m,
since it belongs here. Mark another predicate that writes
to the current output stream as obsolete.
compiler/hlds_error_util.m:
Mark two predicates that wrote out error_spec to the current output
stream as obsolete, and add versions that take an explicit output stream.
compiler/Mercury.options:
Compile the modules that call the newly obsoleted predicates
with --no-warn-obsolete, for the time being.
compiler/*.m:
Conform to the changes above, mostly by updating import_module
declarations, and renaming format_component to format_piece.
|
||
|
|
07f877bc3f |
Carve term_context.m out of term.m.
library/term.m:
library/term_context.m:
As above.
Rename the term.context type as term_context.term_context, with
term.context now being defined as an equivalence type.
Replace the context_init function and predicate and the dummy_context_init
function with just one function: dummy_context. This name includes
the important part (the fact that it return a *dummy* context) and deletes
the nonimportant part (dummy contexts are just about never updated,
so the function does not really "initialize" them).
Reduce function/predicate pairs that do the same thing to just a function.
library/MODULES_DOC:
library/library.m:
Add the new module to the list of standard library modules.
NEWS:
Mention the new module, and the obsoleting of the moved predicates
and functions in term.m.
compiler/*.m:
library/*.m:
Conform to the changes above.
|
||
|
|
41d133b8ad |
Update the "no export" criteria and message.
compiler/check_module_interface.m:
Generate a "this module does not export anything" warning for modules
that contain only single include_module declaration, since such modules
could be deleted with no effect.
Change the warning message to list every kind of declaration/definition
that does not depend on the presence of other kinds of declarations or
definitions.
deep_profiler/Mercury.options:
Shut up this warning for mdprof_fb, since right now, it contains
only a single include_module, even it is designed to later contain more.
tests/invalid/empty_interface.err_exp:
tests/invalid/typeclass_missing_det_3.err_exp:
tests/invalid_nodepend/bigtest.err_exp:
tests/invalid_nodepend/duplicate_modes.err_exp:
tests/invalid_nodepend/errors2.err_exp:
tests/invalid_nodepend/no_exports.err_exp:
tests/invalid_nodepend/prog_io_erroneous.err_exp:
tests/invalid_nodepend/typeclass_test_11.err_exp:
tests/invalid_nodepend/vars_in_wrong_places.err_exp:
Expect the updated wording of the warning message.
|
||
|
|
c99b6777e5 |
Rename check_raw_comp_unit.m to check_module_interface.m.
compiler/check_module_interface.m:
As above. This module has not worked on raw compilation units for a while.
compiler/mercury_compile_main.m:
compiler/parse_tree.m:
compiler/notes/compiler_design.html:
Conform to the change above.
|