mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 04:13:46 +00:00
compiler/add_clause.m:
Generate a warning for mode-specific clauses when the clause is for
a predicate that has only one mode, provided that the warning is enabled.
compiler/options.m:
Add an option to enable this warning.
doc/user_guide.texi:
Document this option.
library/exception.m:
library/int.m:
library/rtti_implementation.m:
library/string.m:
Delete modes from clause heads that would get this warning.
tests/valid/spurious_purity_warning.m:
Delete modes from clause heads that would get this warning.
Do not interleave predicate definitions.
tests/warnings/unneeded_mode_specific_clause.{m,exp}:
A test case for this warning.
tests/warnings/Mmakefile:
Enable the new test case.
tests/invalid/multimode_syntax.err_exp:
Expect the new warning.
38 lines
735 B
Mathematica
38 lines
735 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module spurious_purity_warning.
|
|
:- interface.
|
|
|
|
:- impure pred foo(int::out) is det.
|
|
:- impure pred bar(int::in) is det.
|
|
|
|
:- implementation.
|
|
:- import_module require.
|
|
|
|
foo(X) :-
|
|
( if semidet_succeed then
|
|
error("foo/1")
|
|
else
|
|
X = 5
|
|
).
|
|
|
|
:- pragma foreign_proc("C", foo(X::out),
|
|
[will_not_call_mercury, thread_safe],
|
|
"
|
|
X = 0;
|
|
").
|
|
|
|
bar(_) :-
|
|
( if semidet_succeed then
|
|
error("bar/1")
|
|
else
|
|
true
|
|
).
|
|
|
|
:- pragma foreign_proc("C", bar(_X::in),
|
|
[will_not_call_mercury, thread_safe],
|
|
"
|
|
").
|