aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-06-10 12:12:21 +0200
committerEric Botcazou <ebotcazou@adacore.com>2024-06-10 12:22:32 +0200
commitb5ad4431f97eed60e46fc447fcd1eb4077b3cd80 (patch)
tree09b0bd8d478ecd0ac83742fff1770b6d9273ae13
parent72a59a1b8d4e69b1faac93a31c1162ef0dbe53e5 (diff)
downloadgcc-b5ad4431f97eed60e46fc447fcd1eb4077b3cd80.zip
gcc-b5ad4431f97eed60e46fc447fcd1eb4077b3cd80.tar.gz
gcc-b5ad4431f97eed60e46fc447fcd1eb4077b3cd80.tar.bz2
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.
-rw-r--r--gcc/ada/exp_util.adb6
-rw-r--r--gcc/testsuite/gnat.dg/incomplete8.adb22
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 04d1146..47a928a6 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -6076,6 +6076,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 0000000..63fef59
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/incomplete8.adb
@@ -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;