[Ada] Robust switching from incomplete to access types

Pierre-Marie de Rodat derodat@adacore.com
Tue Jun 15 10:20:51 GMT 2021


When processing an access type declaration that completes an incomplete
type, we now cleanly switch to a proper access type before setting the
designated type. This simplifies the previous ad-hoc machinery for error
recovery, which actually didn't work when the completion as an access
type referenced an unknown subtype name.

After cleaning code with transition from incomplete to access type, the
Directly_Designated_Type field is only needed for access type entities.

An access type declaration must be analysed before mutating the kind of
the type entity from incomplete to access type. The analysis happens
either directly in Analyse (which executed before mutating the kind) or
indirectly in Process_Subtype (which was executed after mutating the
kind).

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

gcc/ada/

	* sem_ch3.adb (Access_Type_Declaration): Add comments to explain
	the ordering of Mutate_Kind and Set_Directly_Designated_Type;
	remove temporary setting of Ekind to E_Access_Type for building
	_master objects, since now the Ekind is already set to its final
	value. Move repeated code into Setup_Access_Type routine and use
	it so that Process_Subtype is executed before mutating the kind
	of the type entity.
	* gen_il-gen-gen_entities.adb (Gen_Entities): Remove
	Directly_Designated_Type from E_Void, E_Private_Record,
	E_Limited_Private_Type and Incomplete_Kind; now it only belongs
	to Access_Kind entities.
	* sem_util.adb: Minor reformatting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 5836 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210615/96e78ce3/attachment.bin>


More information about the Gcc-patches mailing list