* [Ada] Compiler loop on use of a faulty object in an address clause.
@ 2017-05-02 8:26 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-05-02 8:26 UTC (permalink / raw)
To: gcc-patches; +Cc: Ed Schonberg
[-- Attachment #1: Type: text/plain, Size: 855 bytes --]
This patch fixes a loop in the compiler when an address clause is used to
specify an overlay, and the overlaid object has an illegal object declaration
in which the expression is a premature reference to the object itself.
Compiling p.ads must yield:
p.ads:3:33: object "Nowhere" cannot be used before end of its declaration
---
with system; use system;
---
with System; use System;
package P is
Nowhere : constant Address := Nowhere;
Thing : Integer;
for Thing'Address use Nowhere;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-05-02 Ed Schonberg <schonberg@adacore.com>
* sem_ch8.adb (Premature_Usage): If the premature usage of
an entity is as the expression in its own object decaration,
rewrite the reference as Any_Id to prevent cascaded errors or
compiler loops when such an entity is used in an address clause.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 667 bytes --]
Index: sem_ch8.adb
===================================================================
--- sem_ch8.adb (revision 247461)
+++ sem_ch8.adb (working copy)
@@ -8562,6 +8562,14 @@
else
Error_Msg_N
("object& cannot be used before end of its declaration!", N);
+
+ -- If the premature reference appears as the expression in its own
+ -- declaration, rewrite it to prevent compiler loops in subsequent
+ -- uses of this mangled declaration in address clauses.
+
+ if Nkind (Parent (N)) = N_Object_Declaration then
+ Set_Entity (N, Any_Id);
+ end if;
end if;
end Premature_Usage;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-02 8:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 8:26 [Ada] Compiler loop on use of a faulty object in an address clause Arnaud Charlet
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).