]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix crash on access-to-incomplete type
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 10 Jun 2024 10:12:21 +0000 (12:12 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 10 Jun 2024 10:29:32 +0000 (12:29 +0200)
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.

gcc/ada/exp_util.adb
gcc/testsuite/gnat.dg/incomplete8.adb [new file with mode: 0644]

index e18b2ace44b937a4d44164baec66d97486de86a2..5eedd72f5bc9643ad73fef2104f1d80c1bc1e67f 100644 (file)
@@ -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 (file)
index 0000000..63fef59
--- /dev/null
@@ -0,0 +1,22 @@
+-- PR ada/114708
+-- Reported by Jere <jhb.chat@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;