mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 09:23:44 +00:00
If the process of making .int0/.int/.int2 files has no errors other than
missing imports of parent modules (i.e. we import module a.b.c but not a.b),
we have for a while now reported this fact when making those files, which
required programmers to fix the error before they could compile other modules
that need those interface files. However, the fix is obvious: add the missing
imports, either as ":- import_module" or ":- use_module" declarations.
Given this fact, there is no point in interrupting the programmer's workflow:
the compiler can itself add the missing declaration to the interface file
it is generating. Reporting the missing parent imports later, when the module
is compiled to the target language, still guarantees that the programmer will
fix the error, but they can do so at a time of their choosing.
compiler/check_import_accessibility.m:
Report missing parent imports as DelayedSpecs, separately from the Specs
for other kinds of module accessibility errors, to make the above possible.
Report separately the set of parent modules whose imports are missing
from the interface and implementation sections.
Delete an unused function symbol.
compiler/grab_modules.m:
When making the aug_make_int_unit structure from which we generate
.int0/.int/.int2 files, automatically add the missing parent imports
returned by check_import_accessibility.m to it. Actually, add them
as ":- use_module" declarations, since this is the less invasive
alternative. (In the sense that they make the "missing parent import"
error go away, but do not interfere with the detection of *other* kinds
of errors.)
Also, record DelayedSpecs in a new slot in the aug_make_int_unit.
compiler/prog_parse_tree.m:
Add this new slot.
compiler/comp_unit_interface.m:
When making .int0/.int/.int2 files, if there is a reason why
we cannot make them, get the DelayedSpecs from the aug_make_int_unit
and report them together with all other error_specs, since this will
not cause any *added* interruptions to the programmer's workflow.
But in the *absence* of any such reason, throw the DelayedSpecs away.
compiler/module_qual.qualify_items.m:
Conform to the change in prog_parse_tree.m.
compiler/convert_import_use.m:
Improve style.
tests/invalid_submodules/missing_parent_import.err_exp:
tests/invalid_submodules/missing_parent_import.m:
tests/invalid_submodules/missing_parent_import_helper_1.m:
tests/invalid_submodules/missing_parent_import_helper_2.m:
Move this test case here from tests/invalid_make_int, since
after this diff, the compiler no longer reports missing parent imports
when making .int files. Make the test case a bit tougher, since this is
now possible, and update the expected output file to account for the
errors that we never look for when making .int files.
tests/invalid_make_int/Mmakefile:
tests/invalid_submodules/Mmakefile:
Disable the moved test case in its original directory,
108 lines
3.5 KiB
Makefile
108 lines
3.5 KiB
Makefile
#-----------------------------------------------------------------------------#
|
|
# vim: ts=8 sw=8 noexpandtab ft=make
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
TESTS_DIR = ..
|
|
THIS_DIR = invalid_submodules
|
|
MAYBE_J1 = -j1
|
|
|
|
# This directory contains tests for errors in programs in which at least
|
|
# one source file contains more than one nested module. We disable
|
|
# parallel make with the -j1 above, because if we didn't, we would get
|
|
# intermittent failures caused by interface files of nested submodules
|
|
# not being ready when another job, executed in parallel by mmake,
|
|
# wants to read them.
|
|
#
|
|
# For multi-module tests (which includes all the tests in this directory)
|
|
# we normally need to make the dependencies. However, multi-module tests
|
|
# where the error is detected when building the dependencies
|
|
# (e.g. duplicate_module_test.m) should be included in MAKE_DEP_ONLY_PROGS,
|
|
# not STD_PROGS, because we have a specific make rule for them below.
|
|
|
|
STD_PROGS = \
|
|
exported_unify3 \
|
|
missing_parent_import \
|
|
undef_mod_qual \
|
|
unresolved_overloading
|
|
|
|
MAKE_DEP_ONLY_PROGS = \
|
|
duplicate_module_test \
|
|
func_class \
|
|
nested_impl_in_int
|
|
|
|
# XXX The test cases import_in_parent and subtype_submodule are
|
|
# currently disabled, because
|
|
#
|
|
# - we now discover the errors they reports when making .int files,
|
|
# which would require moving them to invalid_make_int, but
|
|
# - this would require adding support for nested submodules to
|
|
# invalid_make_int, and
|
|
# - this is not warranted, because the errors they report are tested for
|
|
# elsewhere.
|
|
#
|
|
# XXX The test case undef_in_ancestor is currently disabled due to the
|
|
# lack of a compatible test setup anywhere in the invalid test directories.
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
PROGS = $(STD_PROGS) $(MAKE_DEP_ONLY_PROGS)
|
|
# For the MAKE_DEP_ONLY_PROGS, we want to make the dependencies
|
|
# using our own rule below, not the usual rule, which is why we disable
|
|
# the usual rule for them via the -nodepend suffix.
|
|
TESTS = $(sort $(STD_PROGS) $(MAKE_DEP_ONLY_PROGS:%=%-nodepend))
|
|
include ../Mmake.common
|
|
|
|
# Module-specific options should go in Mercury.options so they can be found
|
|
# by `mmc --make'.
|
|
include Mercury.options
|
|
|
|
MCFLAGS += --color-diagnostics
|
|
|
|
%.runtest: %.err_res ;
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
ifneq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
|
|
$(STD_PROGS:%=%.err): %.err: %.m
|
|
if $(MC) --errorcheck-only $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) $* \
|
|
> $*.err 2>&1; \
|
|
then false; \
|
|
else true; \
|
|
fi
|
|
|
|
else
|
|
|
|
% XXX: with `mmake --use-mmc-make' the ".DEFAULT:" rule seems to take
|
|
# precedence over "%.err: %.m" rules.
|
|
% XXX: the reason we run the $(MCM) command twice is to avoid doubled up
|
|
# error messages, once while making interface files, then the module proper.
|
|
# The second time the command is run, only one set of error messages
|
|
# should appear.
|
|
$(STD_PROGS:%=%.err):
|
|
-$(MCM) $@
|
|
if $(MCM) -r $@ > /dev/null 2>&1; \
|
|
then false; \
|
|
else true; \
|
|
fi
|
|
|
|
endif
|
|
|
|
# For these test cases, the bug is caught when generating dependencies,
|
|
# so it is easiest just to do that step.
|
|
$(MAKE_DEP_ONLY_PROGS:%=%.err): %.err: %.m
|
|
if $(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) \
|
|
--generate-dependencies $* > $*.err 2>&1; \
|
|
then false; \
|
|
else true; \
|
|
fi
|
|
|
|
$(dates_subdir)undef_mod_qual.date: $(int0s_subdir)undef_mod_qual.int0
|
|
|
|
clean_local: clean_invalid_submodules
|
|
|
|
clean_invalid_submodules:
|
|
rm -f *dep_err *.err *.err_res
|
|
|
|
#-----------------------------------------------------------------------------#
|