-
Notifications
You must be signed in to change notification settings - Fork 12
Address clause #260
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
Address clause #260
Conversation
Target_Type_Irep : constant Irep := | ||
Follow_Symbol_Type | ||
(Get_Type (Target_Name), Global_Symbol_Table); | ||
Expression_Value : constant Uint := Expr_Value (Expression (N)); |
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.
Effectively, this line is what is changed in this commit. And it seems ok.
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.
Looks good.
In regression tests a different node number is given in test address_clause between Mac and Linux. I have changed the expected test.out file to that for Linux. Probably should avoid having node numbers in test.out. Updated golden-results |
( Please make sure this is synchronised with #233 ) |
Use more General Exp_Value rather than IntVal to determine value of "Size" and "Component_Size" IntVal expects an integer literal whereas Exp_Value will accept a static expression and return its folded value.
derivations of existing types or to object declarations. Assertion: pragma Assert (Entity_Esize = UI_From_Int (Int (Get_Width (Target_Type_Irep))) and Entity_Esize = Expression_Value); fails in procedure Handle_Representation_Claise
Probably unwise to have node numbers on regression test outputs.
A little bit more text parsed causing new errors.
Rebased to current diffblue/master and updated golden-results |
gnat2goto is crashing when an address representation clause is encountered. The reason is that gnat2goto was assuming that the expression defining the attribute for all representation clauses is an integer literal. This is certainly not the case for an address clause because a subprogram has to be called to convert the given integer value to a private Address type.
This mod separates out address clauses before the expression is evaluated and reports a missing feature. No doubt we will have to deal with address clauses in the future when we decide how to represent and perform some sort of analysis on them.
Assuming that the expression defining the value of a Size or Component_Size attribute is an integer_literal is also too restrictive, it can be a static_expression. I have replaced IntVal which only accepts an integer_literal with Expr_Value which accepts a static_expression and returns its folded value.
I have added a successful test which defined modular types with a Size representation clause with static_expressions.
I have also added a failing test which legally applies a size representation clause to an object but fails. In addition, size representation clauses applied to derived integer types, again legal in Ada, fails in gnat2goto.
The reason for these failures is the unsatisfied assertion:
-- Just check that the front-end already applied this size
-- clause, i .e. that the size of type-irep we already had
-- equals the entity type this clause is applied to (and the
-- size specified in this clause).
pragma Assert
(Entity_Esize =
UI_From_Int (Int (Get_Width (Target_Type_Irep)))
and Entity_Esize = Expression_Value);
I have not tried to fix this as I am unsure of the GOTO representation that is being used.