From: Marc Poulhiès Date: Tue, 7 Mar 2023 15:35:48 +0000 (+0100) Subject: ada: Fix crash during function return analysis X-Git-Tag: basepoints/gcc-15~8923 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9f355ec846c6dd7a9f4f5ba22eb8642c0b4f37ff;p=thirdparty%2Fgcc.git ada: Fix crash during function return analysis The compiler would crash when checking type relation between the function's return type and the type of the expression used in the return statement. It would not work if the function's return type is an access type and the expression is not. gcc/ada/ * sem_ch6.adb (Analyze_Function_Return): Add missing Is_Access_Type check before accessing the Designated_Type field. --- diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index 7c90747f2931..6df1c8dedd35 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -847,6 +847,7 @@ package body Sem_Ch6 is and then Serious_Errors_Detected = 0 and then Is_Access_Type (R_Type) and then Nkind (Expr) not in N_Null | N_Raise_Expression + and then Is_Access_Type (Etype (Expr)) and then Is_Interface (Designated_Type (R_Type)) and then Is_Progenitor (Designated_Type (R_Type), Designated_Type (Etype (Expr)))