]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Error compiling Ada 2022 object renaming with no subtype mark
authorSteve Baird <baird@adacore.com>
Thu, 7 Dec 2023 00:06:28 +0000 (16:06 -0800)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 9 Jan 2024 13:13:30 +0000 (14:13 +0100)
commit85f0ae3c54ad48e62ca02e61a1aa1ab3c8664142
treef4dd6bd9d3d61b6a5fcb1370660b6587b0262850
parentc1ebec34788353bf126a1df1c75e1ee2110c8795
ada: Error compiling Ada 2022 object renaming with no subtype mark

In some cases the compiler would crash or generate spurious errors
compiling a legal object renaming declaration that lacks a subtype mark.
In addition to fixing the immediate problem, change Atree.Copy_Slots
so that attempts to modify either the Empty or the Error nodes
(e.g., by passing one of them as the target in a call to Rewrite)
are ineffective. Cope with the consequences of this.

gcc/ada/

* sem_ch8.adb (Check_Constrained_Object): Before updating the
subtype mark of an object renaming declaration by calling Rewrite,
first check whether the destination of the Rewrite call exists.
* atree.adb (Copy_Slots): Return without performing any updates if
Destination equals Empty or Error, or if Source equals Empty. Any
of those conditions indicates an error case.
* sem_ch12.adb (Analyze_Formal_Derived_Type): Avoid cascading
errors.
* sem_ch3.adb (Analyze_Number_Declaration): In an error case, do
not pass Error as destination in a call to Rewrite.
(Find_Type_Of_Subtype_Indic): In an error case, do not pass Error
or Empty as destination in a call to Rewrite.
gcc/ada/atree.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch8.adb