This patch fixes a crash in a compilation involving nested generics when
a generic subprogram carries an Inline_Always pragma, and a configuration
file has a corresponding pragma Ignore_Pragma (Inline_Always).

No small example available.

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-04-25  Ed Schonberg  <schonb...@adacore.com>

        * sem_ch12.adb (Load_Parent_Of_Generic); When retrieving the
        declaration of a subprogram instance within its wrapper package,
        skip over null statements that may result from the rewriting of
        ignored pragmas.

Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb        (revision 247182)
+++ sem_ch12.adb        (working copy)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2016, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2017, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -13217,8 +13217,8 @@
                --  package, in which case the usual generic rule applies.
 
                declare
-                  Exp_Status         : Boolean := True;
-                  Scop               : Entity_Id;
+                  Exp_Status : Boolean := True;
+                  Scop       : Entity_Id;
 
                begin
                   --  Loop through scopes looking for generic package
@@ -13292,8 +13292,7 @@
 
                            --  Package instance
 
-                           if
-                             Nkind (Node (Decl)) = N_Package_Instantiation
+                           if Nkind (Node (Decl)) = N_Package_Instantiation
                            then
                               Instantiate_Package_Body
                                 (Info, Body_Optional => True);
@@ -13308,8 +13307,9 @@
                               --  these result in the corresponding pragmas,
                               --  inserted after the subprogram declaration.
                               --  They must be skipped as well when retrieving
-                              --  the desired spec. A direct link would be
-                              --  more robust ???
+                              --  the desired spec. Some of them may have been
+                              --  rewritten as null statements.
+                              --  A direct link would be more robust ???
 
                               declare
                                  Decl : Node_Id :=
@@ -13317,7 +13317,9 @@
                                             (Specification (Info.Act_Decl))));
                               begin
                                  while Nkind_In (Decl,
-                                   N_Subprogram_Renaming_Declaration, N_Pragma)
+                                   N_Null_Statement,
+                                   N_Pragma,
+                                   N_Subprogram_Renaming_Declaration)
                                  loop
                                     Decl := Prev (Decl);
                                  end loop;

Reply via email to