Skip to content

Commit 0e3a640

Browse files
authored
Merge pull request #251 from tjj2017/new_handle_intrinsic
New handle intrinsic
2 parents 021a06e + 1d5e265 commit 0e3a640

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4915,8 +4915,40 @@ package body Tree_Walk is
49154915
-- be called from Ada, or a foreign-language variable to be
49164916
-- accessed from Ada. This would (probably) require gnat2goto to
49174917
-- understand the foreign code, which we do not at the moment.
4918-
Put_Line (Standard_Error,
4919-
"Warning: Multi-language analysis unsupported.");
4918+
-- However, if the calling convention is specified as "Intrinsic"
4919+
-- then the subprogram is built into the compiler and gnat2goto
4920+
-- can safely ignore the pragma.
4921+
declare
4922+
-- If the pragma is specified with positional parameter
4923+
-- association, then the calling convention is the first
4924+
-- parameter. Check to see if it is Intrinsic.
4925+
Next_Ass : Node_Id := First (Pragma_Argument_Associations (N));
4926+
Is_Intrinsic : Boolean := Present (Next_Ass) and then
4927+
Nkind (Expression (Next_Ass)) = N_Identifier and then
4928+
Get_Name_String (Chars (Expression (Next_Ass))) = "intrinsic";
4929+
begin
4930+
-- If the first parameter is not Intrinsic, check named
4931+
-- parameters for calling convention
4932+
while not Is_Intrinsic and Present (Next_Ass) loop
4933+
if Chars (Next_Ass) /= No_Name and then
4934+
Get_Name_String (Chars (Next_Ass)) = "convention"
4935+
then
4936+
-- The named parameter is Convention, check to see if it
4937+
-- is Intrinsic
4938+
Is_Intrinsic :=
4939+
Get_Name_String (Chars (Expression (Next_Ass))) =
4940+
"intrinsic";
4941+
end if;
4942+
-- Get the next parameter association
4943+
Next_Ass := Next (Next_Ass);
4944+
end loop;
4945+
4946+
if not Is_Intrinsic then
4947+
Put_Line (Standard_Error,
4948+
"Warning: Multi-language analysis unsupported.");
4949+
end if;
4950+
end;
4951+
49204952
when Name_Elaborate =>
49214953
-- Specifies that the body of the named library unit is elaborated
49224954
-- before the current library_item. We will support packages.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Standard_Error from gnat2goto use_import:
2+
Warning: Multi-language analysis unsupported.
3+
Warning: Multi-language analysis unsupported.
4+
5+
[overflow.1] file use_import.adb line 16 arithmetic overflow on signed unary minus in -use_import__i: SUCCESS
6+
VERIFICATION SUCCESSFUL
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from test_support import *
2+
3+
prove("--signed-overflow-check")
4+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
procedure Use_Import is
2+
procedure P (X : Integer);
3+
pragma Import (C, P);
4+
5+
procedure Q (X : Integer);
6+
pragma Import (Convention => C, Entity => Q);
7+
8+
function "-" (X : Integer) return Integer;
9+
pragma Import (Convention => Intrinsic, Entity => "-");
10+
11+
function "+" (Left, Right : Integer) return Integer;
12+
pragma Import (Intrinsic, "+");
13+
14+
I : Integer := 1;
15+
begin
16+
I := -I;
17+
end Use_Import;

0 commit comments

Comments
 (0)