Commit Graph

9 Commits

Author SHA1 Message Date
Zoltan Somogyi
c03b11ca48 Update the style of more test cases.
And updated expected outputs for changed line numbers.
2021-07-27 19:29:21 +10:00
Zoltan Somogyi
0584bc300d Expand obsolete pragmas with an optional "suggested replacements" field.
doc/reference_manual.texi:
NEWS:
    Document the extension.

compiler/prog_item.m:
    Add a field to the representation of obsolete pragmas to hold
    an optional list of suggested possible replacements.

compiler/parse_pragma.m:
    Parse the optional second argument in obsolete pragmas.

    Improve the error messages we generate for several kinds of errors
    we may encounter when parsing pragmas by making them more specific.

compiler/hlds_pred.m:
    Since an obsolete pragma now contains more than one bit of information
    (present vs not present), change their representation from a simple marker
    to a field containing the possible replacements.

    Make a comment about access stats more useful by sorting its contents
    on frequency of access, and putting it before the structure it is about.

compiler/simplify_goal_call.m:
    When generating warnings about calls to obsolete predicates or functions,
    mention the suggested replacements, if there are any.

compiler/add_pragma.m:
    Fill in the new field when adding an obsolete pragma to the HLDS.

compiler/globals.m:
    Add a function for use by new codee in parse_pragma.m.

compiler/canonicalize_interface.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_out_pred.m:
compiler/intermod.m:
compiler/item_util.m:
compiler/make_hlds_separate_items.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/recompilation.version.m:
compiler/table_gen.m:
    Conform to the changes above.

tests/invalid/bad_foreign_code.err_exp:
tests/invalid/bad_foreign_enum.err_exp:
tests/invalid/bad_foreign_export.err_exp:
    Expect the improved error messages from parse_pragma.m.

tests/warnings/simple_code.{m,exp}:
    Add tests of the new forms of the obsolete pragma.
2019-09-09 13:53:21 +10:00
Zoltan Somogyi
c7b1a5b743 Clean up some test cases I forgot earlier. 2015-02-27 15:41:25 +11:00
Zoltan Somogyi
fdd141bf77 Clean up the tests in the other test directories.
tests/invalid/*.{m,err_exp}:
tests/misc_tests/*.m:
tests/mmc_make/*.m:
tests/par_conj/*.m:
tests/purity/*.m:
tests/stm/*.m:
tests/string_format/*.m:
tests/structure_reuse/*.m:
tests/submodules/*.m:
tests/tabling/*.m:
tests/term/*.m:
tests/trailing/*.m:
tests/typeclasses/*.m:
tests/valid/*.m:
tests/warnings/*.{m,exp}:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the tests
    that check compiler error messages, expect the new line numbers.

browser/cterm.m:
browser/tree234_cc.m:
    Import only one module per line.

tests/hard_coded/boyer.m:
    Fix something I missed.
2015-02-16 12:32:18 +11:00
Ian MacLarty
ac651b033b Only report mode warnings if they occur in all modes.
Estimated hours taken: 5
Branches: main

Only report mode warnings if they occur in all modes.
simplify.m already had code to remove error_specs that do not occur in all
modes, so move this code to error_util.m and reuse it in modes.m.

Also only report mode warnings for user defined predicates.  Do not report them
for compiler generated predicates (after making the change in the previous
paragraph, the compiler issued a warning for a generated unification predicate
in term_to_xml.m).

compiler/cse_detection.m:
	Conform to new interface of modecheck_proc.

compiler/error_util.m:
	Add an abstract type error_spec_accumulator and predicates for
	working with this type.  The new type is used for accumulating
	errors over multiple modes of a predicate.

	The code for accumulating error specs has been moved from simplify.m.
	There was a bug in this code caused by the arguments of the pair
	in the error_spec_accumulator type getting mixed up.  This bug has now
	been fixed.

	Add mode_report_control to the modecheck phase, so we can mark which
	error specs should only be reported if they occur in all modes.

compiler/mode_errors.m:
	Delete report_mode_errors and report_mode_warnings, since these are
	no longer used.

	Export mode_error_info_to_spec and mode_warning_info_to_spec for
	converting mode errors and warnings to error specs.

	Conform to changes in error_util.m.

compiler/modecheck_unify.m:
	Do not supress warnings if the mode may use a subtype, since we
	want such warnings to be displayed if the occur in all modes.

	Only report mode warnings if the predicate is not a compiler generated
	predicate.

compiler/modes.m:
	Delete modecheck_pred_mode and modecheck_proc_info, since they are
	not used anywhere.

	In modecheck_proc and modecheck_proc_general report a list of
	error specs, instead of the number of errors.  These predicates are
	now no longer responsible for printing the errors, they just return
	the error specs.  We need to do it this way so we can accumulate the
	errors over all modes (eliminating any warnings that don't occur in
	all modes) before printing them.

	Report errors in modecheck_pred_mode_2, after all modes have been
	processed.

	Accumulate the error specs in modecheck_procs, using the new predicates
	in error_util.m.

	Move the code for only reporting the first error encountered for a proc
	from mode_errors.m to here.  Also improve the comment for that bit of
	code.

	Conform to changes in error_util.m.

compiler/pd_util.m:
	Conform to changes in error_util.m.

compiler/simplify.m:
	Move the code for accumulating error specs to error_util.m

compiler/unify_proc.m:
compiler/unique_modes.m:
	Conform to changes elsewhere.

tests/invalid/ho_type_mode_bug.err_exp:
	The order the errors are reported has changed here, because we now
	call write_error_specs to report mode errors.

tests/invalid/qualified_cons_id2.err_exp:
tests/warnings/simple_code.exp:
tests/warnings/simple_code.m:
	We now correctly report a warning we didn't report before.
2007-05-28 01:06:25 +00:00
Fergus Henderson
3018d7abb2 Perform some minor simplifications in mode analysis,
Estimated hours taken: 1.5

Perform some minor simplifications in mode analysis,
so as to provide more information to unique mode analysis.
Previously unique_modes.m was reporting spurious errors
for tests/hard_coded/bidirectional.m, because modes.m
produced output containing a subgoal of the form
`disj([Goal, conj([disj([])]])' instead of just `Goal',
and the presence of a disjunction then caused unique mode
analysis to make overly conservative assumptions.

compiler/modes.m:
	Ensure that we do not produce singleton conjunctions or disjunctions.
	Also, if the result of mode checking a disjunct is a (nested)
	disjunction, then merge it with the containing disjunction.
	If the nested disjunction is the empty disjunction (fail),
	then this means it will be deleted.

tests/hard_coded/Mmakefile:
	Re-enable the test case bidirectional.m, since the compiler now
	accepts it, due to the above change.

tests/warnings/simple_code.m:
tests/warnings/simple_code.exp:
	Update this test case, because the above change meant that the
	compiler no longer issues the warning about "this disjunct can
	never succeed" in cases like this -- mode analysis will already
	have optimized it away, before we even get to simplify.m (which
	handles those kinds of warnings).  This warning is not as
	important as allowing bidirectional code.
1999-04-16 08:08:08 +00:00
Simon Taylor
f2458bd34b Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
Estimated hours taken: 2

Fix a bug reported by Philip Dart where "this disjunct cannot succeed"
warnings for predicates using sub-typing in modes were being output
without a context.

compiler/hlds_goal.m
	Add versions of true_goal and fail_goal which take
	a context for the goal.

compiler/simplify.m
	Pass a valid context to true_goal and fail_goal.
	Only report most of the --warn-simple-code messages if they
	occur for all modes of a predicate - this avoids spurious
	"this disjunct cannot succeed" warnings for sub-typing.

compiler/det_report.m
	Added det_report__is_any_mode_msg to return whether a
	message should only be reported if it occurs for all modes
	of a predicate.

compiler/passes_aux.m
	Add a task type update_pred_error for use by simplify.m.
1998-06-17 05:14:15 +00:00
Tyson Dowd
cbcb23d17b Enable --warn-interface-imports by default.
Estimated hours taken: 3

Enable --warn-interface-imports by default. This was turned off while
list and term were defined in mercury_builtin.m, since it caused many
warnings.

Fix all the unused interface imports that have been added since then.

compiler/options.m:
	Enable --warn-interface-imports by default.

compiler/module_qual.m:
	Fix formatting inconsistencies with module names in warning
	messages. (".m" was not appended to module names if there was
	only one module).

compiler/*.m:
library/*.m:
tests/invalid/type_loop.m:
tests/warnings/*.m:
	Remove usused interface imports, or move them into
	implementation (mostly bool, list and std_util).
1997-05-21 02:16:53 +00:00
Simon Taylor
3a8d2f4ca9 Test cases for the --warn-simple-code warnings.
Estimated hours taken: 0.2

tests/warnings/simple_code.{m,exp}
	Test cases for the --warn-simple-code warnings.
1997-04-28 00:05:26 +00:00