[COMMITTED,19/35] ada: Fix internal error on function call in class-wide precondition

Message ID 20241025091107.485741-19-poulhies@adacore.com
State Committed
Commit 2e3d527fe37e2bf8cba74a42d78f2d99f3e7094a
Headers
Series [COMMITTED,01/35] ada: Pass parameters of full access unconstrained array types by copy in calls |

Commit Message

Marc Poulhiès Oct. 25, 2024, 9:10 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

This occurs when the call is to a function that is declared in a package
that is nested in the scope where the type declaration is located.

gcc/ada/ChangeLog:

	* freeze.adb (Freeze_Expression.In_Expanded_Body): Also return True
	for the body of a helper/wrapper built for class-wide preconditions.

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

---
 gcc/ada/freeze.adb | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 882c026455e..326b39b0545 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8438,6 +8438,14 @@  package body Freeze is
          then
             return True;
 
+         --  This is the body of a helper/wrapper built for CW preconditions
+
+         elsif Present (Corresponding_Spec (P))
+           and then
+             Present (Class_Preconditions_Subprogram (Corresponding_Spec (P)))
+         then
+            return True;
+
          else
             Id := Defining_Unit_Name (Specification (P));