mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-19 19:33:46 +00:00
compiler/add_pragma.m:
When processing a pragma that marks a predicate or function
as external, generate an error message if that predicate or function
has any clauses.
library/profiling_builtin.m:
The predicates that the deep profiler calls at various points
in the code of profiled procedures are marked as external;
their actual implementation is in a script-generated C source file
in the runtime directory. Delete their clauses, since the compiler
would now generate error messages for their external pragmas
in the presence of those clauses.
We don't need those clauses at all, since those predicates should have
no calls to them at all in non-deep-profiling grades. (They are not
documented, and any existing calls to them would have immediately
aborted the program.)
tests/invalid/external2.{m,err_exp}:
A test case for the new functionality.
tests/invalid/Mmakefile:
Enable the new test.
31 lines
594 B
Mathematica
31 lines
594 B
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% This module tests the error message for a predicate that has one or more
|
|
% clauses despite being marked as texternal.
|
|
%
|
|
|
|
:- module external2.
|
|
|
|
:- interface.
|
|
|
|
:- pred p(int::in, int::out) is semidet.
|
|
|
|
:- func f(int) = int.
|
|
|
|
:- implementation.
|
|
|
|
:- pragma external_pred(p/2).
|
|
:- pragma external_func(f/1).
|
|
|
|
p(0, 42).
|
|
p(1, 43).
|
|
|
|
f(A) = X :-
|
|
( if p(A, B) then
|
|
X = B
|
|
else
|
|
X = 0
|
|
).
|