[Ada] Fix check on placement of multiple loop (in)variant pragmas
Loop (in)variants should appear next to each other, which is checked by GNAT frontend. As statements inserted during expansion may break this contiguity, GNAT recognizes specially such statements which originate in loop pragmas. In some cases, this special treatment was not properly put in place, which lead to spurious errors being issued. 2018-05-31 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_prag.adb (Analyze_Pragma.Check_Loop_Pragma_Placement): Inverse order of treatment between nodes recognized as loop pragmas (or generated from one) and block statements. From-SVN: r260996
This commit is contained in:
parent
4cfb305e9c
commit
01f481c77e
2 changed files with 25 additions and 15 deletions
|
@ -1,3 +1,9 @@
|
|||
2018-05-31 Yannick Moy <moy@adacore.com>
|
||||
|
||||
* sem_prag.adb (Analyze_Pragma.Check_Loop_Pragma_Placement): Inverse
|
||||
order of treatment between nodes recognized as loop pragmas (or
|
||||
generated from one) and block statements.
|
||||
|
||||
2018-05-31 Doug Rupp <rupp@adacore.com>
|
||||
|
||||
* libgnat/s-osprim__posix2008.adb (Clock): Implement using
|
||||
|
|
|
@ -5931,23 +5931,9 @@ package body Sem_Prag is
|
|||
Stmt := First (L);
|
||||
while Present (Stmt) loop
|
||||
|
||||
-- Pragmas Loop_Invariant and Loop_Variant may only appear
|
||||
-- inside a loop or a block housed inside a loop. Inspect
|
||||
-- the declarations and statements of the block as they may
|
||||
-- contain the first grouping.
|
||||
|
||||
if Nkind (Stmt) = N_Block_Statement then
|
||||
HSS := Handled_Statement_Sequence (Stmt);
|
||||
|
||||
Check_Grouping (Declarations (Stmt));
|
||||
|
||||
if Present (HSS) then
|
||||
Check_Grouping (Statements (HSS));
|
||||
end if;
|
||||
|
||||
-- First pragma of the first topmost grouping has been found
|
||||
|
||||
elsif Is_Loop_Pragma (Stmt) then
|
||||
if Is_Loop_Pragma (Stmt) then
|
||||
|
||||
-- The group and the current pragma are not in the same
|
||||
-- declarative or statement list.
|
||||
|
@ -6004,6 +5990,24 @@ package body Sem_Prag is
|
|||
|
||||
raise Program_Error;
|
||||
end if;
|
||||
|
||||
-- Pragmas Loop_Invariant and Loop_Variant may only appear
|
||||
-- inside a loop or a block housed inside a loop. Inspect
|
||||
-- the declarations and statements of the block as they may
|
||||
-- contain the first grouping. This case follows the one for
|
||||
-- loop pragmas, as block statements which originate in a
|
||||
-- loop pragma (and so Is_Loop_Pragma will return True on
|
||||
-- that block statement) should be treated in the previous
|
||||
-- case.
|
||||
|
||||
elsif Nkind (Stmt) = N_Block_Statement then
|
||||
HSS := Handled_Statement_Sequence (Stmt);
|
||||
|
||||
Check_Grouping (Declarations (Stmt));
|
||||
|
||||
if Present (HSS) then
|
||||
Check_Grouping (Statements (HSS));
|
||||
end if;
|
||||
end if;
|
||||
|
||||
Next (Stmt);
|
||||
|
|
Loading…
Add table
Reference in a new issue