[Ada] Fix dispatching call to primitive function with controlling tagged result

When a dispatching call is made to a primitive function with a controlling
tagged result, the call is dispatching on result and thus must return the
class-wide type of the tagged type to accommodate all possible results.

This was ensured by Expand_Dispatching_Call only in the common case where
the result type is the type of the controlling argument, which does not
cover the case of a primitive function inherited from an ancestor type.

gcc/ada/

	* exp_disp.adb (Expand_Dispatching_Call): Fix detection of calls
	that are dispatching on tagged result.
1 file changed