Files
mercury/tests/warnings/warn_return.m
Zoltan Somogyi 2448461ae1 Warn about singletons for *all* foreign procs.
compiler/add_foreign_proc.m:
    The existing code for adding foreign_procs

    - tests whether the foreign_proc is for an imported predicate,
      and if so, stops with an error message,

    - then tests whether the foreign_proc is for the current backend,
      and if it is not, ignores the foreign_proc,

    - and then both adds the foreign proc to the HLDS, and checks it
      for singletons.

    Reverse the order of the last two tests, so that we now test
    foreign_procs for singletons *even if* they are not for the current
    backend. (Though of course we do not add such foreign_procs to the HLDS.)

library/io.environment.m:
library/private_builtin.m:
library/rtti_implementation.m:
    Fix the warnings for now result for non-C foreign_procs even during
    bootchecks in C grades.

tests/warnings/foreign_singleton.err_exp:
    Expect warnings for Java and C# foreign_procs as well as C foreign_procs.

tests/warnings/singleton_test.{m,err_exp}:
tests/warnings/warn_return.{m,err_exp}:
tests/warnings/warn_succ_ind.{m,err_exp}:
    Make these test cases more readable. Delete any obsolete parts,
    as well as the causes of warnings that these test cases are
    not intended to test for. (The latter makes the tests' *outputs*
    more readable.)

    Expect warnings for Java and C# foreign_procs as well as C foreign_procs,
    and expect them with the new line numbers.

tests/warnings/foreign_singleton.err_exp2:
tests/warnings/foreign_singleton.err_exp3:
tests/warnings/singleton_test.err_exp2:
tests/warnings/singleton_test.err_exp3:
tests/warnings/warn_return.err_exp2:
tests/warnings/warn_return.err_exp3:
tests/warnings/warn_succ_ind.err_exp2:
tests/warnings/warn_succ_ind.err_exp3:
    Delete these Java- and C#-specific expected outputs, since the warnings
    they test for are now in the corresponding .err_exp files.
2026-01-29 22:09:58 +11:00

71 lines
1.7 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
% Test --warn-suspicious-foreign-procs for return statements.
%
%---------------------------------------------------------------------------%
:- module warn_return.
:- interface.
:- pred foo(int::in, int::out) is det.
:- pred bar(int::in, int::out) is det.
%---------------------------------------------------------------------------%
:- implementation.
%---------------------------------------------------------------------------%
:- pragma foreign_proc("C",
foo(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
return;
").
:- pragma foreign_proc("Java",
foo(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
return;
").
:- pragma foreign_proc("C#",
foo(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
return;
").
%---------------------------------------------------------------------------%
:- pragma foreign_proc("C",
bar(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
// return;
/* return */
").
:- pragma foreign_proc("Java",
bar(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
// return;
/* return */
").
:- pragma foreign_proc("C#",
bar(X::in, Y::out),
[will_not_call_mercury, promise_pure],
"
X = Y;
// return;
/* return */
").
%---------------------------------------------------------------------------%
:- end_module warn_return.
%---------------------------------------------------------------------------%