[COMMITTED] ada: Fix internal error on instance in package body with -gnatn

Message ID 20230515094353.1408487-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix internal error on instance in package body with -gnatn |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 15, 2023, 9:43 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

This plugs a small loophole in the procedure responsible for attempting to
hide entities that have been previously made public by the semantic analyzer
in package bodies.

gcc/ada/

	* sem_ch7.adb (Hide_Public_Entities): Use the same condition for
	subprogram bodies without specification as for those with one.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/sem_ch7.adb | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb
index 7cb7c862d35..1f1fbd3c703 100644
--- a/gcc/ada/sem_ch7.adb
+++ b/gcc/ada/sem_ch7.adb
@@ -446,7 +446,11 @@  package body Sem_Ch7 is
                   else
                      Decl_Id := Defining_Entity (Decl);
 
+                     --  See the N_Subprogram_Declaration case below
+
                      if not Set_Referencer_Of_Non_Subprograms
+                       and then (not In_Nested_Instance
+                                  or else not Subprogram_Table.Get_First)
                        and then not Subprogram_Table.Get (Decl_Id)
                      then
                         --  We can reset Is_Public right away