From: Eric Botcazou Date: Fri, 12 May 2023 18:20:16 +0000 (+0200) Subject: ada: Fix missing error on function call returning incomplete view X-Git-Tag: basepoints/gcc-15~8291 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63a4bcf377ae6594ca84b5dac102ab9f536fc068;p=thirdparty%2Fgcc.git ada: Fix missing error on function call returning incomplete view Testing for the presence of Non_Limited_View is not sufficient to detect whether the nonlimited view has been analyzed because Build_Limited_Views always sets the field on the limited view. Instead the discriminant is whether this nonlimited view is itself an incomplete type. gcc/ada/ * sem_ch4.adb (Analyze_Call): Adjust the test to detect the presence of an incomplete view of a type on a function call. --- diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 02c59284994f..b4b158a3ff49 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -1540,8 +1540,14 @@ package body Sem_Ch4 is Set_Etype (N, Full_View (Etype (N))); + -- If the call is within a thunk, the nonlimited view should be + -- analyzed eventually (see also Analyze_Return_Type). + elsif From_Limited_With (Etype (N)) and then Present (Non_Limited_View (Etype (N))) + and then + (Ekind (Non_Limited_View (Etype (N))) /= E_Incomplete_Type + or else Is_Thunk (Current_Scope)) then Set_Etype (N, Non_Limited_View (Etype (N)));