mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 12:23:44 +00:00
Estimated hours taken: 2 tests/hard_coded/export.m: Fix a bug: the `pragma c_code' declaration did not specify `may_call_mercury' even though the C code actually did call Mercury. This caused it to break when compiled with `-O1' in grade `jump'.
32 lines
498 B
Mathematica
32 lines
498 B
Mathematica
%
|
|
% test case for calling an exported Mercury proc from pragma c_code.
|
|
%
|
|
% author: dgj
|
|
:- module export_test.
|
|
|
|
:- interface.
|
|
|
|
:- import_module int, io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- pred foo(int::in, int::out) is det.
|
|
|
|
:- pred bar(int::in, int::out) is det.
|
|
|
|
:- implementation.
|
|
|
|
main -->
|
|
{ bar(41, X) },
|
|
io__write(X),
|
|
io__write_char('\n').
|
|
|
|
foo(X, X+1).
|
|
|
|
:- pragma export(foo(in, out), "foo").
|
|
|
|
:- pragma c_code(bar(X::in, Y::out), may_call_mercury,
|
|
"
|
|
foo(X, &Y);
|
|
").
|