Skip to content

Conversation

@MartinClochardPro
Copy link

No description provided.

Comment on lines 69 to 70
reference. (visibility as defined by Ada RM is not strict enough,
as ``statement_identifier`` are implicitly declared in innermost declare block)
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

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.

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.

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks.

Copy link
Contributor

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.

Copy link
Author

@MartinClochardPro MartinClochardPro Dec 4, 2025

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants