-
Notifications
You must be signed in to change notification settings - Fork 12
Fix UKNI range issue, and add symbols earlier to the symbol table #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -743,7 +743,9 @@ package body Tree_Walk is | |
|
||
Result_Type : constant Irep := New_Irep (I_Bounded_Signedbv_Type); | ||
begin | ||
if not (Kind (Resolved_Underlying) in Class_Bitvector_Type) then | ||
if not (Kind (Resolved_Underlying) in Class_Bitvector_Type or | ||
Kind (Resolved_Underlying) = I_C_Enum_Type) | ||
then | ||
return Report_Unhandled_Node_Type (Range_Expr, | ||
"Do_Base_Range_Constraint", | ||
"range expression not bitvector type"); | ||
|
@@ -754,6 +756,9 @@ package body Tree_Walk is | |
Store_Nat_Bound (Bound_Type_Nat (Intval (Lower_Bound))); | ||
when N_Attribute_Reference => Lower_Bound_Value := | ||
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Lower_Bound)); | ||
when N_Identifier => | ||
Lower_Bound_Value := | ||
Store_Symbol_Bound (Bound_Type_Symbol (Lower_Bound)); | ||
when others => | ||
Report_Unhandled_Node_Empty (Lower_Bound, | ||
"Do_Base_Range_Constraint", | ||
|
@@ -765,13 +770,21 @@ package body Tree_Walk is | |
Store_Nat_Bound (Bound_Type_Nat (Intval (Upper_Bound))); | ||
when N_Attribute_Reference => Upper_Bound_Value := | ||
Store_Symbol_Bound (Get_Array_Attr_Bound_Symbol (Upper_Bound)); | ||
when N_Identifier => | ||
Upper_Bound_Value := | ||
Store_Symbol_Bound (Bound_Type_Symbol (Upper_Bound)); | ||
when others => | ||
Report_Unhandled_Node_Empty (Upper_Bound, | ||
"Do_Base_Range_Constraint", | ||
"unsupported upper range kind"); | ||
end case; | ||
|
||
Set_Width (Result_Type, Get_Width (Resolved_Underlying)); | ||
if Kind (Resolved_Underlying) = I_C_Enum_Type then | ||
Set_Width (Result_Type, | ||
Get_Width (Get_Subtype (Resolved_Underlying))); | ||
else | ||
Set_Width (Result_Type, Get_Width (Resolved_Underlying)); | ||
end if; | ||
Set_Lower_Bound (Result_Type, Lower_Bound_Value); | ||
Set_Upper_Bound (Result_Type, Upper_Bound_Value); | ||
return Result_Type; | ||
|
@@ -792,23 +805,46 @@ package body Tree_Walk is | |
|
||
procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id); | ||
|
||
function Handle_Enum_Symbol_Members (Mem : Irep) return Irep; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This refers to the |
||
function Handle_Enum_Symbol_Members (Mem : Irep) return Irep is | ||
Followed_Type_Symbol : constant Irep := | ||
Follow_Symbol_Type (Get_Type (Mem), Global_Symbol_Table); | ||
begin | ||
if Kind (Followed_Type_Symbol) = I_C_Enum_Type then | ||
declare | ||
Val : constant Irep := Global_Symbol_Table | ||
(Intern | ||
(Get_Identifier | ||
(Mem))) | ||
.Value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this function returns the initial value for the symbol? What if it's modified? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will need to get back to you on that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @xbauch The symbol is a variable, but they stand in for enum members. Since enum members aren't assignable this should be fine, but I'd prefer if exactly what's going on here would be spelled out in a comment or something. |
||
begin | ||
return | ||
(if Kind (Val) = I_Op_Typecast | ||
then Get_Op0 (Val) else Val); | ||
end; | ||
else | ||
return Mem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the function is identity for non- There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Do you think it's better to be documented? I thought it was obvious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. I was just trying to find out if it was intentional. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe worth spelling out if it's not obvious. |
||
end if; | ||
end Handle_Enum_Symbol_Members; | ||
|
||
---------------------- | ||
-- Handle_Parameter -- | ||
---------------------- | ||
|
||
procedure Handle_Parameter (Formal : Entity_Id; Actual : Node_Id) is | ||
Is_Out : constant Boolean := Out_Present (Parent (Formal)); | ||
Actual_Irep : Irep; | ||
|
||
Expression : constant Irep := Do_Expression (Actual); | ||
begin | ||
if Is_Out and then | ||
not (Kind (Get_Type (Do_Expression (Actual))) in Class_Type) | ||
not (Kind (Get_Type (Expression)) in Class_Type) | ||
then | ||
Report_Unhandled_Node_Empty (Actual, "Handle_Parameter", | ||
"Kind of actual not in class type"); | ||
return; | ||
end if; | ||
Actual_Irep := Wrap_Argument (Do_Expression (Actual), Is_Out); | ||
Actual_Irep := Wrap_Argument ( | ||
Handle_Enum_Symbol_Members (Expression), Is_Out); | ||
Append_Argument (Args, Actual_Irep); | ||
end Handle_Parameter; | ||
|
||
|
@@ -2882,6 +2918,8 @@ package body Tree_Walk is | |
|
||
-- Begin processing for Do_Object_Declaration_Full_Declaration | ||
|
||
Is_In_Symtab : constant Boolean := | ||
Global_Symbol_Table.Contains (Intern (Get_Identifier (Id))); | ||
begin | ||
Set_Source_Location (Decl, (Sloc (N))); | ||
Set_Symbol (Decl, Id); | ||
|
@@ -2907,6 +2945,12 @@ package body Tree_Walk is | |
Rhs => Init_Expr, | ||
Source_Location => Sloc (N))); | ||
end if; | ||
|
||
if not Is_In_Symtab then | ||
Register_Identifier_In_Symbol_Table | ||
(Id, Init_Expr, Global_Symbol_Table); | ||
end if; | ||
|
||
end Do_Object_Declaration_Full; | ||
|
||
------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
procedure Range_Constraint is | ||
type Indicator_Type is ( | ||
CALIBRATION_MODE, | ||
MEASUREMENT_MODE, | ||
CALIBRATION_PASS, | ||
CALIBRATION_FAIL, | ||
MEASUREMENT_NOT_PROVEN, | ||
MEASUREMENT_PRESENT); | ||
|
||
-- this particular test is testing a syntactic fix for ranges constraint by enum symbols. | ||
subtype Result_Indicator_Type is Indicator_Type range CALIBRATION_PASS .. MEASUREMENT_NOT_PROVEN; | ||
begin | ||
null; | ||
end Range_Constraint; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERIFICATION SUCCESSFUL |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from test_support import * | ||
|
||
prove() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
procedure Range_Constraint is | ||
type Indicator_Type is ( | ||
CALIBRATION_MODE, | ||
MEASUREMENT_MODE, | ||
CALIBRATION_PASS, | ||
CALIBRATION_FAIL, | ||
MEASUREMENT_NOT_PROVEN, | ||
MEASUREMENT_PRESENT); | ||
|
||
subtype Result_Indicator_Type is Indicator_Type range CALIBRATION_PASS .. MEASUREMENT_NOT_PROVEN; | ||
|
||
-- this test is here because subtype assignment is broken and needs to be activated againt when fixed | ||
Value : constant Result_Indicator_Type := CALIBRATION_FAIL; | ||
begin | ||
pragma assert (Value = CALIBRATION_FAIL); | ||
end Range_Constraint; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALL XFAIL symex is crashing at the assignment because of wrong code generation. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VERIFICATION SUCCESSFUL |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from test_support import * | ||
|
||
prove() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems sketchy.
enumeration_typet
does not have a width field, seems like you're basically invoking UB here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
enumeration_typet
doesn't have awidth
field, but it has a subtype that has awidth
field.