[Ada] AI12-0095 Formal types and Constrained Partial Views

Pierre-Marie de Rodat derodat@adacore.com
Thu Oct 22 12:12:12 GMT 2020


AI12-0095 is a binding interpretation that revises the RM to have a
general rule about how generic formal discriminated types are considered
to have a constrained partial view within generic bodies, rather than
just have this rule appear in the sections of the RM on Access
attributes and type conversions, so that rule now also applies on the
rules for passing aliased parameters. GNAT was already implementing this
interpretation properly for parameters in generic bodies, but it was
noticed that a case involving Access in the spec of a generic unit was
not properly enforced in instantiations. If an Access attribute is
applied in a generic spec to a constrained aliased object of a formal
type with discriminants and in an instantiation the actual type has a
constrained partial view, then the Access attribute should be rejected
in the instantiation (assuming the access type in the generic has the
formal type as a designated subtype, with no constraint imposed). The
compiler was applying the function Has_Constrained_Partial_View to the
subtype that is created to rename the actual rather than to that
subtype's base type, so got a result of False rather than True. That
function is changed to apply Base_Type to its formal. Another fix is for
the case of a call with an aliased parameter of such a formal type that
occurs in a generic spec, which was incorrectly being flagged as
illegal, when it should be allowed in the generic spec and only rejected
in an instance (when the actual has a constrained partial view).

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* einfo.adb (Has_Constrained_Partial_View): Apply Base_Type to Id.
	* sem_res.adb (Resolve_Actuals.Check_Aliased_Parameter): Remove
	"not Is_Generic_Type" test and call
	Object_Type_Has_Constrained_Partial_View instead of
	Has_Constrained_Partial_View. Improve related error message to
	say "does not statically match" instead of just "does not
	match".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 1250 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201022/d87f5e0b/attachment-0001.bin>


More information about the Gcc-patches mailing list