https://gcc.gnu.org/g:12a3ba2be46e86ff1bffa5c876b6b17fe4929be3
commit r12-10501-g12a3ba2be46e86ff1bffa5c876b6b17fe4929be3 Author: Eric Botcazou <ebotca...@adacore.com> Date: Mon Jun 10 12:12:21 2024 +0200 Fix crash on access-to-incomplete type This just adds the missing guard. gcc/ada/ PR ada/114708 * exp_util.adb (Finalize_Address): Add guard for incomplete types. gcc/testsuite/ * gnat.dg/incomplete8.adb: New test. Diff: --- gcc/ada/exp_util.adb | 6 ++++++ gcc/testsuite/gnat.dg/incomplete8.adb | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index e18b2ace44b..5eedd72f5bc 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -5866,6 +5866,12 @@ package body Exp_Util is Utyp := Underlying_Type (Base_Type (Utyp)); + -- Handle incomplete types + + if No (Utyp) then + return Empty; + end if; + -- Deal with untagged derivation of private views. If the parent is -- now known to be protected, the finalization routine is the one -- defined on the corresponding record of the ancestor (corresponding diff --git a/gcc/testsuite/gnat.dg/incomplete8.adb b/gcc/testsuite/gnat.dg/incomplete8.adb new file mode 100644 index 00000000000..63fef59e866 --- /dev/null +++ b/gcc/testsuite/gnat.dg/incomplete8.adb @@ -0,0 +1,22 @@ +-- PR ada/114708 +-- Reported by Jere <jhb.c...@gmail.com> + +-- { dg-do compile } + +procedure Incomplete8 is + + generic + type Element_Type(<>); + package Test_Incomplete_Formal is + type Element_Access is access Element_Type; + end Test_Incomplete_Formal; + + type Node; + + package P is new Test_Incomplete_Formal(Node); + + type Node is limited null record; + +begin + null; +end;