Fix gcc warnings in some test cases.

tests/hard_coded/target_mlobjs_c.c:
    Fix a bad use of printf.

tests/hard_coded/trace_goal_4.m:
tests/hard_coded/word_aligned_pointer.m:
tests/hard_coded/word_aligned_pointer_2.m:
tests/tabling/memo_non.m:
tests/tabling/table_foreign_output.m:
tests/tabling/test_enum.m:
    Don't assume that MR_Integers are ints; print them using
    MR_INTEGER_LENGTH_MODIFIER.
This commit is contained in:
Zoltan Somogyi
2018-07-30 09:26:12 +10:00
parent 16e6459517
commit ffb357724f
7 changed files with 17 additions and 14 deletions

View File

@@ -3,5 +3,5 @@
void c_write_string(char *string)
{
printf(string);
printf("%s", string);
}

View File

@@ -15,12 +15,12 @@
:- implementation.
main(!IO) :-
(
( if
trace [] impure progress_report(1),
fail
->
then
true
;
else
trace [] impure progress_report(2)
).
@@ -30,7 +30,7 @@ main(!IO) :-
progress_report(X::in),
[will_not_call_mercury, thread_safe, tabled_for_io],
"
printf(""Progress reported %d\\n"", X);
printf(""Progress reported %"" MR_INTEGER_LENGTH_MODIFIER ""d\\n"", X);
").
:- pragma foreign_proc("C#",

View File

@@ -43,10 +43,10 @@ main(!IO) :-
write_bar(Bar, !IO) :-
(
Bar = yes(Foo),
format("yes(0x%x)\n", [i(get_foo(Foo))], !IO)
io.format("yes(0x%x)\n", [i(get_foo(Foo))], !IO)
;
Bar = no,
write_string("no", !IO)
io.write_string("no", !IO)
).
%---------------------------------------------------------------------------%

View File

@@ -55,7 +55,8 @@ make_foo = foo(0xcafe).
[will_not_call_mercury, promise_pure, thread_safe],
"
if (X != MR_strip_tag(X)) {
fprintf(stderr, ""tag bits not clear in value 0x%x\\n"", X);
fprintf(stderr, ""tag bits not clear in value""
""0x%"" MR_INTEGER_LENGTH_MODIFIER ""x\\n"", (MR_Unsigned) X);
abort();
}
Int = MR_unmkbody(X);
@@ -76,10 +77,10 @@ make_bar = yes(make_foo).
write_bar(Bar, !IO) :-
(
Bar = yes(Foo),
format("yes(0x%x)\n", [i(get_foo(Foo))], !IO)
io.format("yes(0x%x)\n", [i(get_foo(Foo))], !IO)
;
Bar = no,
write_string("no", !IO)
io.write_string("no", !IO)
).
%---------------------------------------------------------------------------%

View File

@@ -76,6 +76,7 @@ test_multi(A, B, C) :-
marker(S::in, A::in, B::in, X::out),
[will_not_call_mercury],
"
printf(""marker executed: %s %d %d\\n"", S, A, B);
printf(""marker executed: %s %"" MR_INTEGER_LENGTH_MODIFIER ""d %""
MR_INTEGER_LENGTH_MODIFIER ""d\\n"", S, A, B);
X = 0;
").

View File

@@ -68,7 +68,7 @@ test_memo(Pairs, F) :-
"
Foreign *p;
printf(""make_foreign(%d, %s)\\n"", N, S);
printf(""make_foreign(%"" MR_INTEGER_LENGTH_MODIFIER ""d, %s)\\n"", N, S);
p = (Foreign *) malloc(sizeof(Foreign));
if (p == NULL) {
exit(1);
@@ -88,7 +88,8 @@ test_memo(Pairs, F) :-
"
Foreign *p;
printf(""make_foreign_memo(%d, %s)\\n"", N, S);
printf(""make_foreign_memo(%"" MR_INTEGER_LENGTH_MODIFIER ""d, %s)\\n"",
N, S);
p = (Foreign *) malloc(sizeof(Foreign));
if (p == NULL) {
exit(1);

View File

@@ -57,6 +57,6 @@ get_start_state(StartCond, Anchor) = State :-
test_exec(In::in, Out::out),
[will_not_call_mercury, promise_pure, thread_safe],
"
printf(""test_exec %d\\n"", In);
printf(""test_exec %"" MR_INTEGER_LENGTH_MODIFIER ""d\\n"", In);
Out = In + 1;
").