From 2a127979d92caafe31a2c9be5d9f5bb70e1f4d98 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 14 Aug 2019 09:51:39 +0000 Subject: [PATCH] [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. 2019-08-14 Eric Botcazou 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. From-SVN: r274457 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/sem_ch12.adb | 4 ---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gnat.dg/generic_inst11.adb | 9 +++++++++ gcc/testsuite/gnat.dg/generic_inst11_pkg.adb | 21 ++++++++++++++++++++ gcc/testsuite/gnat.dg/generic_inst11_pkg.ads | 5 +++++ 6 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/generic_inst11.adb create mode 100644 gcc/testsuite/gnat.dg/generic_inst11_pkg.adb create mode 100644 gcc/testsuite/gnat.dg/generic_inst11_pkg.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 99b551f1d0c..a36a83ab3d2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2019-08-14 Eric Botcazou + + * 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. + 2019-08-14 Ed Schonberg * exp_ch4.adb (Expand_N_Quantified_Expression): Freeze diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index f98f2fa49a7..5f290acbe32 100644 --- a/gcc/ada/sem_ch12.adb +++ b/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. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9923987ec42..89a92fa2583 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-08-14 Eric Botcazou + + * gnat.dg/generic_inst11.adb, gnat.dg/generic_inst11_pkg.adb, + gnat.dg/generic_inst11_pkg.ads: New testcase. + 2019-08-14 Ed Schonberg * gnat.dg/assert2.adb, gnat.dg/assert2.ads: New testcase. diff --git a/gcc/testsuite/gnat.dg/generic_inst11.adb b/gcc/testsuite/gnat.dg/generic_inst11.adb new file mode 100644 index 00000000000..75c19a590be --- /dev/null +++ b/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; diff --git a/gcc/testsuite/gnat.dg/generic_inst11_pkg.adb b/gcc/testsuite/gnat.dg/generic_inst11_pkg.adb new file mode 100644 index 00000000000..b90f8bb982b --- /dev/null +++ b/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; diff --git a/gcc/testsuite/gnat.dg/generic_inst11_pkg.ads b/gcc/testsuite/gnat.dg/generic_inst11_pkg.ads new file mode 100644 index 00000000000..07ee9f64a3e --- /dev/null +++ b/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; -- 2.30.2