[m-rev.] diff: fix library compliation in non-C grades
Julien Fischer
jfischer at opturion.com
Fri Jun 19 23:33:00 AEST 2020
Fix library compilation in non-C grades.
The recent change to enable --warn-dead-predicates in the library directory
broke standard library compilation due to various predicates being dead in some
grades.
library/io.m:
Add a default Mercury clause for compare_file_id_2/3; having a Java one
that throws a (Java) exception results in the Java compiler complaining
about unreachable code when compare_file_id_2 is inlined in its caller.
Add consider_used pragmas where necessary.
library/erlang_rtti_implementation.m:
library/rtti_implementation.m:
library/time.m:
library/version_array.m:
Add consider_used pragmas where necessary.
Julien.
diff --git a/library/erlang_rtti_implementation.m b/library/erlang_rtti_implementation.m
index e6e82ac..a27e74e 100644
--- a/library/erlang_rtti_implementation.m
+++ b/library/erlang_rtti_implementation.m
@@ -2221,6 +2221,7 @@ result_call_9(_::in, (=)::out, _::in, _::in, _::in, _::in, _::in,
%---------------------------------------------------------------------------%
:- pred semidet_unimplemented(string::in) is semidet.
+:- pragma consider_used(semidet_unimplemented/1).
semidet_unimplemented(S) :-
( if semidet_succeed then
@@ -2230,6 +2231,7 @@ semidet_unimplemented(S) :-
).
:- pred det_unimplemented(string::in) is det.
+:- pragma consider_used(det_unimplemented/1).
det_unimplemented(S) :-
( if semidet_succeed then
diff --git a/library/io.m b/library/io.m
index 378e379..42f7484 100644
--- a/library/io.m
+++ b/library/io.m
@@ -10125,6 +10125,7 @@ read_file_as_string_2(Stream, String, NumCUs, Error, NullCharError, !IO) :-
:- pred read_file_as_string_loop(input_stream::in, buffer::buffer_di,
buffer::buffer_uo, int::in, int::out, int::in, int::out, system_error::out,
io::di, io::uo) is det.
+:- pragma consider_used(read_file_as_string_loop/10).
read_file_as_string_loop(Stream, !Buffer, BufferSize0, BufferSize,
!NumCUs, Error, !IO) :-
@@ -10261,6 +10262,7 @@ read_binary_file_as_bitmap_2(Stream, BufferSize, Res, !BMs, !IO) :-
% XXX FIXME this should return an int64.
:- pred input_stream_file_size(io.input_stream::in, int::out,
io::di, io::uo) is det.
+:- pragma consider_used(input_stream_file_size/4).
input_stream_file_size(input_stream(Stream), Size, !IO) :-
stream_file_size(Stream, Size64, !IO),
@@ -10354,6 +10356,7 @@ binary_input_stream_file_size(binary_input_stream(Stream), Size, !IO) :-
:- mode buffer_uo == out(uniq_buffer).
:- pred alloc_buffer(int::in, buffer::buffer_uo) is det.
+:- pragma consider_used(alloc_buffer/2).
:- pragma foreign_proc("C",
alloc_buffer(Size::in, Buffer::buffer_uo),
@@ -10416,6 +10419,7 @@ resize_buffer(_OldSize, NewSize, buffer(Array0), buffer(Array)) :-
array.resize(NewSize, Char, Array0, Array).
:- pred buffer_to_string(buffer::buffer_di, int::in, string::uo) is semidet.
+:- pragma consider_used(buffer_to_string/3).
:- pragma foreign_proc("C",
buffer_to_string(Buffer::buffer_di, Len::in, Str::uo),
@@ -13799,6 +13803,7 @@ typedef struct {
:- pred compare_file_id(comparison_result::uo, file_id::in, file_id::in)
is det.
+:- pragma consider_used(compare_file_id/3).
compare_file_id(Result, FileId1, FileId2) :-
compare_file_id_2(Result0, FileId1, FileId2),
@@ -13844,12 +13849,8 @@ compare_file_id(Result, FileId1, FileId2) :-
}
").
-:- pragma foreign_proc("Java",
- compare_file_id_2(_Res::out, _FileId1::in, _FileId2::in),
- [will_not_call_mercury, promise_pure, thread_safe],
-"
- throw new RuntimeException(""File IDs are not supported by Java."");
-").
+compare_file_id_2(_, _, _) :-
+ unexpected($pred, "File IDs are not supported by Java").
:- pragma foreign_proc("Erlang",
compare_file_id_2(Res::out, FileId1::in, FileId2::in),
diff --git a/library/rtti_implementation.m b/library/rtti_implementation.m
index 0848e1f..e7d1b8f 100644
--- a/library/rtti_implementation.m
+++ b/library/rtti_implementation.m
@@ -4360,6 +4360,7 @@ set_type_info_index(_, _, _, !TypeInfo) :-
%---------------------%
:- pred semidet_unimplemented(string::in) is semidet.
+:- pragma consider_used(semidet_unimplemented/1).
semidet_unimplemented(S) :-
( if semidet_succeed then
@@ -4369,6 +4370,7 @@ semidet_unimplemented(S) :-
).
:- pred det_unimplemented(string::in) is det.
+:- pragma consider_used(det_unimplemented/1).
det_unimplemented(S) :-
( if semidet_succeed then
@@ -5182,6 +5184,7 @@ notag_functor_arg_name(NoTagFunctorDesc) = NoTagFunctorDesc ^ unsafe_index(2).
% XXX get rid of this
:- func unsafe_index(int, T) = U.
+:- pragma consider_used(unsafe_index/2).
:- pragma foreign_proc("C#",
unsafe_index(_Num::in, _Array::in) = (Item::out),
[will_not_call_mercury, thread_safe, promise_pure],
@@ -5195,6 +5198,7 @@ unsafe_index(_, _) = _ :-
:- pred null(T::in) is semidet.
:- pragma no_determinism_warning(null/1).
+:- pragma consider_used(null/1).
:- pragma foreign_proc("C",
null(S::in),
diff --git a/library/time.m b/library/time.m
index b1aad4b..fb46813 100644
--- a/library/time.m
+++ b/library/time.m
@@ -532,7 +532,7 @@ clk_tck = Ret :-
).
:- func c_clk_tck = int.
-
+:- pragma consider_used(c_clk_tck/0).
:- pragma foreign_proc("C",
c_clk_tck = (Ret::out),
[will_not_call_mercury, promise_pure, thread_safe],
diff --git a/library/version_array.m b/library/version_array.m
index e753d76..7d14594 100644
--- a/library/version_array.m
+++ b/library/version_array.m
@@ -761,6 +761,7 @@ unsafe_rewind(VA, unsafe_rewind(VA)).
:- pred eq_version_array(version_array(T)::in, version_array(T)::in)
is semidet.
:- pragma terminates(eq_version_array/2).
+:- pragma consider_used(eq_version_array/2). % For the Erlang grade.
eq_version_array(VAa, VAb) :-
N = max(VAa),
@@ -781,6 +782,7 @@ eq_version_array_2(I, VAa, VAb) :-
:- pred cmp_version_array(comparison_result::uo,
version_array(T)::in, version_array(T)::in) is det.
:- pragma terminates(cmp_version_array/3).
+:- pragma consider_used(cmp_version_array/3). % For the Erlang grade.
cmp_version_array(R, VAa, VAb) :-
SizeA = VAa ^ size,
More information about the reviews
mailing list