Skip to content

Commit

Permalink
ada: Fix crash during function return analysis
Browse files Browse the repository at this point in the history
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.

Tested on x86_64-pc-linux-gnu, committed on master.
  • Loading branch information
dkm authored and ouuleilei-bot committed May 25, 2023
1 parent c2d62cd commit e7128ea
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions gcc/ada/sem_ch6.adb
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,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)))
Expand Down

0 comments on commit e7128ea

Please sign in to comment.