Skip to content

Commit 2fe20c6

Browse files
committed
Modular subtype indication is unsigned
and so we need to extend the range checking interface to accept unsigned.
1 parent dcd1005 commit 2fe20c6

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

gnat2goto/driver/range_check.adb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ package body Range_Check is
228228
(Value_Expr);
229229
begin
230230
pragma Assert (Kind (Bound_Type) in
231-
I_Bounded_Signedbv_Type | I_Bounded_Floatbv_Type);
231+
I_Bounded_Unsignedbv_Type
232+
| I_Bounded_Signedbv_Type
233+
| I_Bounded_Floatbv_Type);
232234
-- The compared expressions (value and bound) have to be of the
233235
-- same type
234236
if Get_Width (Bound_Type) > Get_Width (Value_Expr_Type)

gnat2goto/driver/range_check.ads

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ package Range_Check is
2121

2222
function Get_Bound (Bound_Type : Irep; Pos : Bound_Low_Or_High) return Irep
2323
with Pre => Kind (Bound_Type) in
24-
I_Bounded_Signedbv_Type | I_Bounded_Floatbv_Type,
24+
I_Bounded_Unsignedbv_Type | I_Bounded_Signedbv_Type
25+
| I_Bounded_Floatbv_Type,
2526
Post => Kind (Get_Bound'Result) in Class_Expr;
2627

2728
function Make_Range_Assert_Expr (N : Node_Id; Value : Irep;

gnat2goto/driver/tree_walk.adb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,10 @@ package body Tree_Walk is
754754
Lower_Bound_Value : Integer;
755755
Upper_Bound_Value : Integer;
756756

757-
Result_Type : constant Irep := New_Irep (I_Bounded_Signedbv_Type);
757+
Result_Type : constant Irep :=
758+
New_Irep (if Kind (Resolved_Underlying) = I_Ada_Mod_Type
759+
then I_Bounded_Unsignedbv_Type
760+
else I_Bounded_Signedbv_Type);
758761
begin
759762
if not (Kind (Resolved_Underlying) in Class_Bitvector_Type or
760763
Kind (Resolved_Underlying) = I_C_Enum_Type)
@@ -771,7 +774,8 @@ package body Tree_Walk is
771774
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Lower_Bound));
772775
when N_Identifier =>
773776
Lower_Bound_Value :=
774-
Store_Symbol_Bound (Bound_Type_Symbol (Lower_Bound));
777+
Store_Symbol_Bound (Bound_Type_Symbol (
778+
Do_Identifier (Lower_Bound)));
775779
when others =>
776780
Report_Unhandled_Node_Empty (Lower_Bound,
777781
"Do_Base_Range_Constraint",
@@ -785,7 +789,8 @@ package body Tree_Walk is
785789
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Upper_Bound));
786790
when N_Identifier =>
787791
Upper_Bound_Value :=
788-
Store_Symbol_Bound (Bound_Type_Symbol (Upper_Bound));
792+
Store_Symbol_Bound (Bound_Type_Symbol (
793+
Do_Identifier (Upper_Bound)));
789794
when others =>
790795
Report_Unhandled_Node_Empty (Upper_Bound,
791796
"Do_Base_Range_Constraint",
@@ -2961,7 +2966,8 @@ package body Tree_Walk is
29612966

29622967
if Init_Expr /= Ireps.Empty then
29632968
Append_Op (Block, Make_Code_Assign (Lhs => Id,
2964-
Rhs => Init_Expr,
2969+
Rhs => Typecast_If_Necessary (Init_Expr, Get_Type (Id),
2970+
Global_Symbol_Table),
29652971
Source_Location => Sloc (N)));
29662972
end if;
29672973

0 commit comments

Comments
 (0)