This patch updates predicate Null_Status to prevent an infinite
recursion when the argument is an illegal object declaration of an
access type.
2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
gcc/ada/
* sem_util.adb (Null_Status): Assume that an erroneous construct
has an undefined null status.
gcc/testsuite/
* gnat.dg/self_ref1.adb: New testcase.
From-SVN: r273389
+2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * sem_util.adb (Null_Status): Assume that an erroneous construct
+ has an undefined null status.
+
2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
* checks.adb, exp_ch6.adb, gnat1drv.adb, sem_aux.adb,
-- Start of processing for Null_Status
begin
+ -- Prevent cascaded errors or infinite loops when trying to determine
+ -- the null status of an erroneous construct.
+
+ if Error_Posted (N) then
+ return Unknown;
+
-- An allocator always creates a non-null value
- if Nkind (N) = N_Allocator then
+ elsif Nkind (N) = N_Allocator then
return Is_Non_Null;
-- Taking the 'Access of something yields a non-null value
+2019-07-11 Hristian Kirtchev <kirtchev@adacore.com>
+
+ * gnat.dg/self_ref1.adb: New testcase.
+
2019-07-11 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/predicate11.adb: New testcase.
--- /dev/null
+-- { dg-do compile }
+
+procedure Self_Ref1 is
+ type Integer_Ptr is access all Integer;
+ Ptr : constant Integer_Ptr := Integer_Ptr (Ptr); -- { dg-error "object \"Ptr\" cannot be used before end of its declaration" }
+
+begin
+ if Ptr /= null then
+ null;
+ end if;
+end Self_Ref1;