diff options
author | Steve Baird <baird@adacore.com> | 2024-09-05 13:42:20 -0700 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2024-10-08 10:37:13 +0200 |
commit | 0f7e027e7773fbab82b24e08f60c6da7d3f913a5 (patch) | |
tree | 3298d9b863baa53ece1df2aec200b6fba5907505 /gcc | |
parent | 0171938cfc357ed43c2b95ddee504f614cac7982 (diff) | |
download | gcc-0f7e027e7773fbab82b24e08f60c6da7d3f913a5.zip gcc-0f7e027e7773fbab82b24e08f60c6da7d3f913a5.tar.gz gcc-0f7e027e7773fbab82b24e08f60c6da7d3f913a5.tar.bz2 |
ada: Improved support for incomplete parameter types
Fix two bugs uncovered by a recent ACATS test C3A1005: a freezing problem
and a case where a user-defined equality function for an incomplete type
was incorrectly hidden from use-clause visibility by the "corresponding"
predefined op (which doesn't actually exist).
gcc/ada/ChangeLog:
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Don't freeze here
if Has_Delayed_Freeze returns True.
* sem_type.adb (Valid_Equality_Arg): Treat an incomplete type like
a limited type because neither has an implicitly-defined equality
primitive.
(Covers): If either argument is an incomplete type
whose full view is available, then look through to the full view.
* sem_res.adb (Resolve_Actuals): If the actual parameter type is
complete and the formal parameter type is not, then update the
formal parameter type to use the complete view.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch6.adb | 4 | ||||
-rw-r--r-- | gcc/ada/sem_res.adb | 9 | ||||
-rw-r--r-- | gcc/ada/sem_type.adb | 15 |
3 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index c200871..8cf191d 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -4135,7 +4135,9 @@ package body Sem_Ch6 is Set_Is_Public (Body_Id, False); end if; - Freeze_Before (N, Body_Id); + if not Has_Delayed_Freeze (Body_Id) then + Freeze_Before (N, Body_Id); + end if; end if; if Nkind (N) /= N_Subprogram_Body_Stub then diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index c8652ee..6b673a9 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -4658,6 +4658,15 @@ package body Sem_Res is A_Typ := Etype (A); F_Typ := Etype (F); + -- If A_Typ is complete and F_Typ is not, then adjust F_Typ + + if Ekind (F_Typ) = E_Incomplete_Type + and then Present (Full_View (F_Typ)) + and then not Is_Incomplete_Type (A_Typ) + then + F_Typ := Full_View (F_Typ); + end if; + -- An actual cannot be an untagged formal incomplete type if Ekind (A_Typ) = E_Incomplete_Type diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb index b76c6ef..75e7daf 100644 --- a/gcc/ada/sem_type.adb +++ b/gcc/ada/sem_type.adb @@ -1228,6 +1228,18 @@ package body Sem_Type is return Has_Non_Limited_View (T2) and then Covers (T1, Get_Full_View (Non_Limited_View (T2))); + -- Coverage for incomplete types + + elsif Ekind (T1) = E_Incomplete_Type + and then Present (Full_View (T1)) + then + return Covers (Full_View (T1), T2); + + elsif Ekind (T2) = E_Incomplete_Type + and then Present (Full_View (T2)) + then + return Covers (T1, Full_View (T2)); + -- Ada 2005 (AI-412): Coverage for regular incomplete subtypes elsif Ekind (T1) = E_Incomplete_Subtype then @@ -3586,6 +3598,9 @@ package body Sem_Type is if Is_Anonymous_Access_Type (T) then return Ada_Version >= Ada_2005; + elsif Is_Incomplete_Type (T) then + return False; + elsif not Is_Limited_Type (T) then return True; |