[Ada] Fix bogus compilation error with Elaborate_Body and -gnatN

This fixes a bogus compilation error when a unit with SPARK_Mode
containing a pragma Elaborate_Body is with-ed by a generic unit
containing an inlined subprogram, and front-end inlining is enabled.

2019-08-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

	* sem_prag.adb (Is_Before_First_Decl): Deal with rewritten
	pragmas.

gcc/testsuite/

	* gnat.dg/elab8.adb, gnat.dg/elab8_gen.adb,
	gnat.dg/elab8_gen.ads, gnat.dg/elab8_pkg.adb,
	gnat.dg/elab8_pkg.ads: New testcase.

From-SVN: r274664
This commit is contained in:
Eric Botcazou 2019-08-19 08:37:28 +00:00 committed by Pierre-Marie de Rodat
parent bfa6962fc2
commit 8fafa0b420
8 changed files with 56 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2019-08-19 Eric Botcazou <ebotcazou@adacore.com>
* sem_prag.adb (Is_Before_First_Decl): Deal with rewritten
pragmas.
2019-08-19 Bob Duff <duff@adacore.com>
* sem_warn.adb (Warn_On_Unreferenced_Entity): Suppress warning

View File

@ -7146,10 +7146,11 @@ package body Sem_Prag is
Item : Node_Id := First (Decls);
begin
-- Only other pragmas can come before this pragma
-- Only other pragmas can come before this pragma, but they might
-- have been rewritten so check the original node.
loop
if No (Item) or else Nkind (Item) /= N_Pragma then
if No (Item) or else Nkind (Original_Node (Item)) /= N_Pragma then
return False;
elsif Item = Pragma_Node then

View File

@ -1,3 +1,9 @@
2019-08-19 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/elab8.adb, gnat.dg/elab8_gen.adb,
gnat.dg/elab8_gen.ads, gnat.dg/elab8_pkg.adb,
gnat.dg/elab8_pkg.ads: New testcase.
2019-08-19 Bob Duff <duff@adacore.com>
* gnat.dg/warn29.adb, gnat.dg/warn29.ads: New testcase.

View File

@ -0,0 +1,12 @@
-- { dg-do compile }
-- { dg-options "-gnatN" }
with Elab8_Gen;
procedure Elab8 is
package My_G is new Elab8_Gen (Integer);
begin
My_G.Compare (0, 1);
end;

View File

@ -0,0 +1,12 @@
with Elab8_Pkg;
package body Elab8_Gen is
procedure Compare (Arg1, Arg2 : T) is
begin
if Arg1 = Arg2 then
raise Program_Error;
end if;
end;
end Elab8_Gen;

View File

@ -0,0 +1,8 @@
generic
type T is private;
package Elab8_Gen is
procedure Compare (Arg1, Arg2 : T);
pragma Inline (Compare);
end Elab8_Gen;

View File

@ -0,0 +1,5 @@
package body Elab8_Pkg is
procedure Dummy is null;
end Elab8_Pkg;

View File

@ -0,0 +1,5 @@
package Elab8_Pkg with SPARK_Mode is
pragma Elaborate_Body;
end Elab8_Pkg;