aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch6.adb
diff options
context:
space:
mode:
authorMarc Poulhiès <poulhies@adacore.com>2023-03-07 16:35:48 +0100
committerMarc Poulhiès <poulhies@adacore.com>2023-05-25 09:44:17 +0200
commit9f355ec846c6dd7a9f4f5ba22eb8642c0b4f37ff (patch)
tree266474154f27ccb7413565217ab3204617fe036c /gcc/ada/sem_ch6.adb
parent8f7eeaa80e58af3885107d67679b2f8ca8dcb2f8 (diff)
downloadgcc-9f355ec846c6dd7a9f4f5ba22eb8642c0b4f37ff.zip
gcc-9f355ec846c6dd7a9f4f5ba22eb8642c0b4f37ff.tar.gz
gcc-9f355ec846c6dd7a9f4f5ba22eb8642c0b4f37ff.tar.bz2
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.
Diffstat (limited to 'gcc/ada/sem_ch6.adb')
-rw-r--r--gcc/ada/sem_ch6.adb1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 7c90747..6df1c8d 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)))