[Ada] Plug loophole in Possible_Type_For_Conditional_Expression

We need to check that the designated subprograms of access-to-subprogram
types are subtype conformant before registering a common interpretation.

gcc/ada/

	* sem_ch4.adb (Possible_Type_For_Conditional_Expression): Add
	test for subtype conformance in the cases of
	access-to-subprogram types.
This commit is contained in:
Eric Botcazou 2022-02-09 17:16:09 +01:00 committed by Pierre-Marie de Rodat
parent bcbf83ec10
commit 9da379f1c2
1 changed files with 4 additions and 0 deletions

View File

@ -7904,11 +7904,15 @@ package body Sem_Ch4 is
elsif Is_Access_Subprogram_Attribute (T1)
and then Is_Access_Subprogram_Attribute (T2)
and then
Subtype_Conformant (Designated_Type (T1), Designated_Type (T2))
then
return T1;
elsif Is_Access_Protected_Subprogram_Attribute (T1)
and then Is_Access_Protected_Subprogram_Attribute (T2)
and then
Subtype_Conformant (Designated_Type (T1), Designated_Type (T2))
then
return T1;