[COMMITTED] ada: Fix spurious error on imported generic function with precondition

Message ID 20230529082958.2411374-1-poulhies@adacore.com
State Committed
Commit fb828af5933219d95f0f6a98567c09813de2dde1
Headers
Series [COMMITTED] ada: Fix spurious error on imported generic function with precondition |

Commit Message

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

It occurs during the instantiation because the compiler forgets the context
of the generic declaration.

gcc/ada/

	* freeze.adb (Wrap_Imported_Subprogram): Use Copy_Subprogram_Spec in
	both cases to copy the spec of the subprogram.

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

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

Patch

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 5d3413c1505..8ebf10bd576 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -6063,12 +6063,6 @@  package body Freeze is
          then
             --  Here we do the wrap
 
-            --  Note on calls to Copy_Separate_Tree. The trees we are copying
-            --  here are fully analyzed, but we definitely want fully syntactic
-            --  unanalyzed trees in the body we construct, so that the analysis
-            --  generates the right visibility, and that is exactly what the
-            --  calls to Copy_Separate_Tree give us.
-
             Prag := Copy_Import_Pragma;
 
             --  Fix up spec so it is no longer imported and has convention Ada
@@ -6127,7 +6121,7 @@  package body Freeze is
                 Specification              => Copy_Subprogram_Spec (Spec),
                 Declarations               => New_List (
                   Make_Subprogram_Declaration (Loc,
-                    Specification => Copy_Separate_Tree (Spec)),
+                    Specification => Copy_Subprogram_Spec (Spec)),
                   Prag),
                 Handled_Statement_Sequence =>
                   Make_Handled_Sequence_Of_Statements (Loc,