Files
mercury/tests/warnings/format_call_warning.exp
Zoltan Somogyi a32d6a16f4 Add the format_call pragma to the language.
doc/reference_manual.texi:
NEWS:
    Document and announce the new pragma.

compiler/prog_data_pragma.m:
compiler/prog_item.m:
    Provide a representation for the new pragma. The part that ends up
    being referred to from the HLDS goes into prog_data_pragma.m,
    the part that is not needed once the HLDS has been constructed
    goes into prog_item.m.

compiler/hlds_pred.m:
    Add a slot to pred_infos for info from the new pragma.

    Fix a bug in the comment on marker_has_format_call.

compiler/add_pragma.m:
    Add the information in these pragmas to the HLDS.

compiler/check_pragma_format_call.m:
    A new module to check the validity of format_call pragmas.
    These checks test whether the arguments named in such pragmas
    have the expected types and modes, which means that
    the check must be done after both type and mode checking.

compiler/check_hlds.m:
compiler/notes/compiler_design.html:
    Add and document the new module.

compiler/hlds_module.m:
    Add a field to the module_info that records the set of pred_ids
    that have format_call pragmas.

compiler/mercury_compile_front_end.m:
    Invoke the check_pragma_format_call pass *provided* that
    the new field in the module_info says it has any pragmas to check.

compiler/parse_pragma.m:
    Add code to parse the new pragma.

compiler/format_call.m:
    Check calls to predicates and functions with the new pragma
    the same way as we check calls to string.format, io.format,
    and stream.string_writer.format.

    This required separating the code that checked calls to such predicates
    from the code that optimized calls to such predicates, since

    - a predicate or function with a format_call pragma that specifies
      more than one argument pair has to have its correctness checked
      for each pair, and

    - a predicate or function with a format_call pragma does not actually
      do any formatting, so that formatting cannot be optimized.

    Fix an old bug, where we included the function result in the function's
    reported arity, which meant that an error message could mention a call
    to a nonexistent function. As part of that fix, the error message
    now specifies whether it is complaining about a call to a predicate
    or a function.

    Change the exported interface of this module a bit
    in order to allow the factoring out of repeated code.

compiler/parse_string_format.m:
    Separate the parsing of format strings from their optimization,
    again because calls to predicates and functions with format_call
    pragmas need to be checked but cannot be optimized.

compiler/polymorphism.m:
    Record the effect on argument numbers of any type_info and/or
    typeclass_info arguments added by this pass.

compiler/convert_parse_tree.m:
compiler/det_analysis.m:
compiler/direct_arg_in_out.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_out_pred.m:
compiler/item_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/recompilation.version.m:
compiler/simplify_proc.m:
    Conform to the changes above.

tests/invalid/bad_format_call.{m,err_exp}:
    A new test case to see whether check_pragma_format_call.m detects
    and reports invalid format_call pragmas as expected.

tests/warnings/format_call_warning.{m,exp}:
tests/warnings/format_call_warning_helper.m:
    A new test case to see whether we generate the expected set of error
    messages for incorrect calls to a predicate with a format_call pragma.

tests/invalid/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
    Enable the new test cases.

tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
tests/warnings/disabled_warning.exp:
    Expect the predicate vs function distinction to the printed in
    error messages about bad calls to formatting predicates and functions.
2022-09-24 08:42:36 +10:00

59 lines
4.0 KiB
Plaintext

format_call_warning.m:030: Mismatched format and values in call to predicate
format_call_warning.m:030: `format_call_warning.maybe_log_msg'/10 when
format_call_warning.m:030: considering the first entry in its
format_call_warning.m:030: `:- pragma format_call' declaration, which places
format_call_warning.m:030: the format string as the third argument, and the
format_call_warning.m:030: values list as the fourth argument:
format_call_warning.m:030: There is no second conversion specifier, but there
format_call_warning.m:030: is an extra input.
format_call_warning.m:030: Mismatched format and values in call to predicate
format_call_warning.m:030: `format_call_warning.maybe_log_msg'/10 when
format_call_warning.m:030: considering the second entry in its
format_call_warning.m:030: `:- pragma format_call' declaration, which places
format_call_warning.m:030: the format string as the third argument, and the
format_call_warning.m:030: values list as the fifth argument:
format_call_warning.m:030: There is no second conversion specifier, but there
format_call_warning.m:030: is an extra input.
format_call_warning.m:030: Mismatched format and values in call to predicate
format_call_warning.m:030: `format_call_warning.maybe_log_msg'/10 when
format_call_warning.m:030: considering the third entry in its
format_call_warning.m:030: `:- pragma format_call' declaration, which places
format_call_warning.m:030: the format string as the sixth argument, and the
format_call_warning.m:030: values list as the seventh argument:
format_call_warning.m:030: The first conversion specifier uses the specifier
format_call_warning.m:030: character `f', but the corresponding input is a
format_call_warning.m:030: string. The only specifier applicable to strings
format_call_warning.m:030: is %s.
format_call_warning.m:030: Mismatched format and values in call to predicate
format_call_warning.m:030: `format_call_warning.maybe_log_msg'/10 when
format_call_warning.m:030: considering the fourth entry in its
format_call_warning.m:030: `:- pragma format_call' declaration, which places
format_call_warning.m:030: the format string as the sixth argument, and the
format_call_warning.m:030: values list as the eighth argument:
format_call_warning.m:030: The first conversion specifier uses the specifier
format_call_warning.m:030: character `f', but the corresponding input is a
format_call_warning.m:030: string. The only specifier applicable to strings
format_call_warning.m:030: is %s.
format_call_warning.m:035: Mismatched format and values in call to predicate
format_call_warning.m:035: `format_call_warning.maybe_log_msg'/10 when
format_call_warning.m:035: considering the second entry in its
format_call_warning.m:035: `:- pragma format_call' declaration, which places
format_call_warning.m:035: the format string as the third argument, and the
format_call_warning.m:035: values list as the fifth argument:
format_call_warning.m:035: There is no second conversion specifier, but there
format_call_warning.m:035: is an extra input.
format_call_warning.m:045: Mismatched format and values in call to predicate
format_call_warning.m:045: `format_call_warning.maybe_log_simple_msg'/6:
format_call_warning.m:045: The second conversion specifier uses the specifier
format_call_warning.m:045: character `f', but the corresponding input is a
format_call_warning.m:045: string. The only specifier applicable to strings
format_call_warning.m:045: is %s.
format_call_warning.m:048: Mismatched format and values in call to predicate
format_call_warning.m:048: `format_call_warning_helper.maybe_log_imported_msg'/6:
format_call_warning.m:048: The first conversion specifier uses the specifier
format_call_warning.m:048: character `s', but the corresponding input is a
format_call_warning.m:048: float. The specifiers applicable to floats are %f,
format_call_warning.m:048: %e, %E, %g and %G.
format_call_warning.m:083: Unknown format values in call to predicate
format_call_warning.m:083: `io.format'/4.