committed: fix for PR 17540

Arnaud Charlet charlet@ACT-Europe.FR
Mon Sep 20 14:46:00 GMT 2004


Tested on i686-linux

gnatlib compiled with -O0 due to unrelated ssa failures.

This patch addresses PR 17540. In previous versions of GNAT, the
Is_Imported and Is_Public flags of objects were set if a pragma
Import was given, even if an Address clause was also present. This
is not really right, as in this case, the Ada RM specifies that
the only effect of the pragma Import is to suppress default
implicit initialization. Previous versions of the back end
however did the right thing in ignoring these flags in this
situation, but that's not true of the latest version of the
back end. Rather than kludge to ignore these flags, this simple
patch to freeze resets the flags Is_Public and Is_Imported if
an address clause is present.


2004-09-20  Robert Dewar  <dewar@gnat.com>

	PR ada/17540

	* freeze.adb (Check_Address_Clause): Reset Is_Imported and Is_Public
	if an address clause is present, since that means that the Import
	should be ignored.
-------------- next part --------------
Index: freeze.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/freeze.adb,v
retrieving revision 1.20
diff -u -p -r1.20 freeze.adb
--- freeze.adb	9 Aug 2004 12:24:15 -0000	1.20
+++ freeze.adb	20 Sep 2004 10:47:51 -0000
@@ -82,7 +82,9 @@ package body Freeze is
 
    procedure Check_Address_Clause (E : Entity_Id);
    --  Apply legality checks to address clauses for object declarations,
-   --  at the point the object is frozen.
+   --  at the point the object is frozen. Also deals with cancelling effect
+   --  of Import pragma which has no effect (other than to eliminate any
+   --  implicit initialization) if an address clause is present.
 
    procedure Check_Strict_Alignment (E : Entity_Id);
    --  E is a base type. If E is tagged or has a component that is aliased
@@ -497,6 +499,11 @@ package body Freeze is
          then
             Warn_Overlay (Expr, Typ, Name (Addr));
          end if;
+
+         --  Cancel effect of any Import pragma
+
+         Set_Is_Imported (E, False);
+         Set_Is_Public (E, False);
       end if;
    end Check_Address_Clause;
 


More information about the Gcc-patches mailing list