-
Notifications
You must be signed in to change notification settings - Fork 30
Proposal for referring to values at labels #182
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
base: master
Are you sure you want to change the base?
Proposal for referring to values at labels #182
Conversation
| reference. (visibility as defined by Ada RM is not strict enough, | ||
| as ``statement_identifier`` are implicitly declared in innermost declare block) |
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.
Can you give an example to illustrate this?
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.
To my understanding this means that something like
X := 1;
<<My_Label>>
X := 2;
declare
Y : Integer := 0;
begin
pragma Assert ((X-1)'At (My_Label) = Y);
end;is not allowed.
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.
A label is declared in the innermost declare block enclosing the label. So this would be legal.
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.
A few lines below: "Furthermore, the statement_identifier referenced by an 'At attribute and the attribute itself shall have the same innermost enclosing body."
To my understanding, this would make it illegal as <<My_Label>> and (X-1)'At (My_Label) do not have the same innermost enclosing body.
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.
Enclosing body is not the same as enclosing declare block. A "body" refers to a function, procedure, task, or package body.
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.
Can you give an example to illustrate this?
Something like
declare
X : Integer := 0;
begin
X := 1;
if Condition then
<<L>>
X := 2;
end if;
pragma Assert ((X-1)'At (L) = 1);
end;must not be allowed. However Ada language rules states that the label L is declared in the innermost enclosing declare block, which makes it visible at the assertion.
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.
I see, thanks.
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 "goto" statement legality rule is similar, and perhaps you should copy as nearly as possible the wording of 5.8(4):
The innermost sequence_of_statements that encloses the target statement shall also enclose the goto_statement. Furthermore, if a goto_statement is enclosed by an accept_statement or a body, then the target statement shall not be outside this enclosing construct.
So, perhaps:
The innermost sequence_of_statements that encloses the target statement shall also enclose the At reference. Furthermore, if an At reference is enclosed by an accept_statement or a body, then the target statement shall not be outside this enclosing construct.
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.
I incorporated the change, modulo using "statement_identifier" instead of the "target statement".
0287839 to
80a8f4a
Compare
No description provided.