This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix internal error on inlined subprogram instance


This fixes a long-standing oddity in the procedure analyzing the
instantiation of a generic subprogram, which would set the
Is_Generic_Instance flag on the enclosing package generated for the
instantiation but only to reset it a few lines below.  Now this flag is
relied upon by the machinery which computes the set of public entities
to be exposed by a package.

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

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

gcc/ada/

	* sem_ch12.adb (Analyze_Instance_And_Renamings): Do not reset
	the Is_Generic_Instance flag previously set on the package
	generated for the instantiation of a generic subprogram.

gcc/testsuite/

	* gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb,
	gnat.dg/generic_inst11_pkg.ads: New testcase.
--- gcc/ada/sem_ch12.adb
+++ gcc/ada/sem_ch12.adb
@@ -5264,10 +5264,6 @@ package body Sem_Ch12 is
 
          Analyze (Pack_Decl);
          Check_Formal_Packages (Pack_Id);
-         Set_Is_Generic_Instance (Pack_Id, False);
-
-         --  Why do we clear Is_Generic_Instance??? We set it 20 lines
-         --  above???
 
          --  Body of the enclosing package is supplied when instantiating the
          --  subprogram body, after semantic analysis is completed.

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/generic_inst11.adb
@@ -0,0 +1,9 @@
+--  { dg-do compile }
+--  { dg-options "-O -gnatn" }
+
+with Generic_Inst11_Pkg;
+
+procedure Generic_Inst11 is
+begin
+   Generic_Inst11_Pkg.Proc;
+end;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/generic_inst11_pkg.adb
@@ -0,0 +1,21 @@
+with System;
+
+package body Generic_Inst11_Pkg is
+
+   Data : Integer;
+
+   generic
+      Reg_Address : System.Address;
+   procedure Inner_G with Inline;
+
+   procedure Inner_G is
+      Reg : Integer with Address => Reg_Address;
+   begin
+      null;
+   end;
+
+   procedure My_Inner_G is new Inner_G (Data'Address);
+
+   procedure Proc renames My_Inner_G;
+
+end Generic_Inst11_Pkg;

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/generic_inst11_pkg.ads
@@ -0,0 +1,5 @@
+package Generic_Inst11_Pkg is
+
+   procedure Proc with Inline;
+
+end Generic_Inst11_Pkg;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]