!ASIS Issue #063 !topic How to deal with pragmas between two labels attached to the same statement ? !from Alain Le Guennec !keywords label pragma Corresponding_Destination_Statement !discussion Please consider the following example : with Ada.Text_IO; use Ada.Text_IO; procedure Sample17 is begin <> pragma Annotate (Label1); pragma Debug (Put_Line ("A label pragma.")); <> Put_Line ("The statement itself."); delay 2.0; -- goto Label1; goto Label2; end Sample17; If my understanding of the RM is correct, then Label1 and Label2 are _both_ attached to the same statement. In that case, the two pragmas I inserted inbetween can't be considered as statements, since it changes the result of the query Asis.Statements.Corresponding_Destination_Statement when applied to 'goto Label1' or 'goto Label2' (the result should be the same in both cases, shouldn't it ?). Note however that when compiled with 'gnatmake -cargs -gnata', the program seems to work _as if_ the pragmas were considered as statements, since the statement inside the Debug prama is re-executed only if the goto label is Label1, not for Label2. If ASIS wants to deal with such pragmas as if they were statements, then I think this particular case should be documented somewhere, and Corresponding_Destination_Statement result profile should be changed from Asis.Statement to Asis.Element to allow for A_Pragma as a possible result type for this query. An other alternative is to allow pragmas to be returned by Asis.Statements.Label_Names. !resolution Accepted, with Modifications. !date 97-03-26 !Notes With respect to the above example, ASIS should not treat pragmas as statements. Also, the result of the Corresponding_Destination_Statement should be the real Put_Line statement. Evidently, pragma Debug is an implementation defined pragma. This means that its semantics can not be defined by ASIS. A tool however, could apply those semantics in some way by using existing ASIS queries to determine the location of the labels and pragmas. The lesson is to be aware of pragmas when you try to determine the span. The following Application Note has been added to Subclause 18.23, Corresponding_Destination_Statement as follows: --|AN Application Note: --|AN --|AN The Reference Manual allows a pragma between a statement and a label --|AN attached to it. If so, when the label is passed as an actual parameter --|AN to this query, the query returns the statement, but not the label. --|AN The only way for an application to know that there are any pragmas --|AN between a statement and its label is to get the spans of these program --|AN elements and analyze the corresponding positions in the source text. Changes have been made to ASIS version 2.0.M.