Files
mercury/tests/warnings/bug412.err_exp
Zoltan Somogyi 36e8833145 Add a new option, --warn-unused-types.
When set, this option tells the compiler to generate warnings
about locally-defined types that are neither used in the module
nor exported to any other module.

compiler/options.m:
    Add the new option.

compiler/unused_types.m:
    New module to implement the new option.

compiler/mercury_compile_front_end.m:
    Invoke the new module, unless the presence of previous errors
    would make its warnings just a distraction.

compiler/check_hlds.m:
    Include the new module.

compiler/notes/compiler_design.html:
    Document the new module.

compiler/typecheck_error_wrong_type.m:
    Simplify some code.

browser/declarative_tree.m:
compiler/accumulator.m:
compiler/du_type_layout.m:
compiler/intermod.m:
compiler/mode_errors.m:
compiler/parse_inst_mode_defn.m:
compiler/polyhedron.m:
compiler/split_parse_tree_src.m:
compiler/tag_switch_util.m:
compiler/typecheck_error_unify.m:
compiler/unneeded_code.m:
deep_profiler/mdprof_test.m:
library/getopt.m:
library/getopt_io.m:
    Delete unused types reported by the new option.

library/rtti_implementation.m:
    Comment out unused type reported by the new option. This type was exported
    to both Java and C#, but this diff comments it out because neither language
    the Java or the C# runtime system seems to use the exported versions
    either. (Bootcheck in both java and csharp grades worked, with the
    same number of test case failures as before.) We do not delete it,
    because it may be useful in the future.

tests/warnings/help_text.err_exp:
    Expect the documentation of the new option.

tests/invalid_nodepend/Mmakefile:
    Specify --warn-unused-types for two test cases to test that the compiler
    does NOT generate warnings about unused types in the presence of previous
    errors.

tests/warnings/abstract_type_decl.err_exp:
tests/warnings/bug412.err_exp:
tests/warnings/warn_dead_procs.err_exp:
    Expect the new warnings for unused types.

tests/warnings/Mmakefile:
    Specify --warn-unused-types for the three test cases listed above.
2026-02-15 11:26:34 +11:00

1.2 KiB

bug412.m:008: In module `bug412':
bug412.m:008: warning: module bool has an `:- import_module' declaration in
bug412.m:008: the interface, but is not used in the interface.
bug412.m:018: Warning: type constructor `blah2'/0 is unused.
bug412.m:021: In module `bug412':
bug412.m:021: warning: the following modules have `:- import_module'
bug412.m:021: declarations, but are not used anywhere in the module.
bug412.m:021: module bitmap
bug412.m:022: module bit_buffer
bug412.m:024: module char
bug412.m:025: module diet
bug412.m:026: module digraph
bug412.m:027: module enum
bug412.m:028: module io
bug412.m:029: module ops
bug412.m:030: module pprint
bug412.m:031: module rtree
bug412.m:032: module store
bug412.m:033: module stream
bug412.m:034: module string
bug412.m:035: module string.builder
bug412.m:037: module term
bug412.m:038: module univ