Skip to content

Commit db0e132

Browse files
Petr BauchPetr Bauch
authored andcommitted
Add support to ignore refine pragmas
1 parent f9d214e commit db0e132

File tree

1 file changed

+55
-2
lines changed

1 file changed

+55
-2
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ package body Tree_Walk is
407407

408408
procedure Declare_Itype (Ty : Entity_Id) is
409409
begin
410-
if Is_Itype (Ty) then
410+
if Present (Ty) and then Is_Itype (Ty) then
411411
declare
412412
Ty_Name : constant Symbol_Id := Intern (Unique_Name (Ty));
413413
Ty_Symbol : Symbol;
@@ -2128,6 +2128,8 @@ package body Tree_Walk is
21282128
-- Handle pragmas that suppress some checks by explicitly ignoring them
21292129
procedure Do_Pragma_Suppress
21302130
(N_Orig : Node_Id);
2131+
procedure Do_Pragma_Refine
2132+
(N_Orig : Node_Id);
21312133

21322134
procedure Do_Pragma_Assert_or_Assume
21332135
(N_Orig : Node_Id; Block : Irep)
@@ -2227,6 +2229,54 @@ package body Tree_Walk is
22272229

22282230
end Do_Pragma_Suppress;
22292231

2232+
procedure Do_Pragma_Refine
2233+
(N_Orig : Node_Id)
2234+
is
2235+
-- To be set by iterator:
2236+
Components : List_Id;
2237+
Component_Expression : Node_Id;
2238+
CEE : List_Id;
2239+
Scope_Size : Nat;
2240+
2241+
----------------
2242+
-- Handle_Arg --
2243+
----------------
2244+
2245+
procedure Handle_Arg
2246+
(Arg_Pos : Positive; Arg_Name : Name_Id; Expr : Node_Id);
2247+
2248+
procedure Handle_Arg
2249+
(Arg_Pos : Positive; Arg_Name : Name_Id; Expr : Node_Id) is
2250+
begin
2251+
2252+
if Arg_Name = No_Name and then
2253+
Arg_Pos = 1 and then
2254+
Nkind (Expr) = N_Aggregate
2255+
then
2256+
Components := Component_Associations (Expr);
2257+
Component_Expression := Expression (First (Components));
2258+
CEE := Expressions (Component_Expression);
2259+
Scope_Size := List_Length (CEE);
2260+
else
2261+
Report_Unhandled_Node_Empty (N, "Do_Pragma_Suppress",
2262+
"Unknown arg name");
2263+
end if;
2264+
end Handle_Arg;
2265+
2266+
procedure Iterate_Args is new
2267+
Iterate_Pragma_Parameters (Handle_Arg => Handle_Arg);
2268+
2269+
begin
2270+
Iterate_Args (N_Orig);
2271+
if Scope_Size > 1
2272+
then
2273+
null; -- Intentionally ignoring this request to suppress all checks
2274+
else
2275+
null; -- Intentionally ignoring supressing some checks
2276+
end if;
2277+
2278+
end Do_Pragma_Refine;
2279+
22302280
N_Orig : Node_Id;
22312281

22322282
begin
@@ -2241,8 +2291,11 @@ package body Tree_Walk is
22412291
when Name_Annotate =>
22422292
-- Ignore here. Rather look for those when we process a node.
22432293
null;
2294+
when Name_Refined_State | Name_Refined_Global |
2295+
Name_Refined_Depends =>
2296+
Do_Pragma_Refine (N_Orig);
22442297
when Name_SPARK_Mode | Name_Global | Name_Postcondition |
2245-
Name_Refined_State | Name_Refined_Global | Name_Precondition =>
2298+
Name_Precondition =>
22462299
-- These pragmas are currently unimplemented
22472300
Report_Unhandled_Node_Empty (N, "Do_Pragma",
22482301
"Unsupported pragma");

0 commit comments

Comments
 (0)