From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Hristian Kirtchev <kirtchev@adacore.com>
Subject: [Ada] Infinite loop on illegal declaration
Date: Thu, 11 Jul 2019 08:05:00 -0000 [thread overview]
Message-ID: <20190711080343.GA95173@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 414 bytes --]
This patch updates predicate Null_Status to prevent an infinite
recursion when the argument is an illegal object declaration of an
access type.
Tested on x86_64-pc-linux-gnu, committed on trunk
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.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 981 bytes --]
--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -22367,9 +22367,15 @@ package body Sem_Util is
-- 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
--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/self_ref1.adb
@@ -0,0 +1,11 @@
+-- { 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;
reply other threads:[~2019-07-11 8:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190711080343.GA95173@adacore.com \
--to=derodat@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kirtchev@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).