[Ada] Internal error compiling formal instance of generic with Initial_Condition

Message ID 20220912081931.GA1512981@poulhies-Precision-5550
State New, archived
Headers
Series [Ada] Internal error compiling formal instance of generic with Initial_Condition |

Commit Message

Marc Poulhiès Sept. 12, 2022, 8:19 a.m. UTC
  Prevent the compiler from failing with an internal error in some cases involving
an instance of a generic which takes as a formal parameter an instance of a
second generic, where the second generic has an Initial_Condition aspect
specification.

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

gcc/ada/

	* contracts.adb
	(Analyze_Package_Contract): Do not analyze the contract of a
	temporary package created just to check conformance of an actual
	package.
  

Patch

diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -1319,6 +1319,18 @@  package body Contracts is
       if Present (Items) then
          if Analyzed (Items) then
             return;
+
+         --  Do not analyze the contract of the internal package
+         --  created to check conformance of an actual package.
+         --  Such an internal package is removed from the tree after
+         --  legality checks are completed, and it does not contain
+         --  the declarations of all local entities of the generic.
+
+         elsif Is_Internal (Pack_Id)
+           and then Is_Generic_Instance (Pack_Id)
+         then
+            return;
+
          else
             Set_Analyzed (Items);
          end if;