diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-05-22 13:22:58 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-05-22 13:22:58 +0000 |
commit | 85c73d636947efcb3555ce521c6064717a559615 (patch) | |
tree | 0474ec7b7792640047568d0ca5b55c8a0881cad5 | |
parent | 714835398ed533b90d9bae265c176ac9bcdf5af3 (diff) | |
download | gcc-85c73d636947efcb3555ce521c6064717a559615.zip gcc-85c73d636947efcb3555ce521c6064717a559615.tar.gz gcc-85c73d636947efcb3555ce521c6064717a559615.tar.bz2 |
[Ada] Spurious visibility error on aspect in generic unit
This patch fixes a spurious visiblity error on an instantiation of a generic
package that contains a type declaration with an aspect specification for
an aspect that must be delayed (i.e. an aspect whose value may be specified
at a later point).
The package g.ads must compile quietly:
----
with S;
generic
package G
is
type Buffer_Type is record
Data : Integer;
end record;
package Buffer is new S (Buffer_Type => Buffer_Type);
end G;
----
generic
type Buffer_Type is private;
package S
is
Page_Size : constant := 4096;
type Reader_Type is limited record
Data : Buffer_Type;
end record
with
Alignment => Page_Size; -- Using a constant does not work
-- Alignment => 4096; -- Using a number works
-- for Reader_Type'Alignment use Page_Size; -- so does an attribute.
pragma Compile_Time_Error (Reader_Type'Size /= 12345, "Ooops");
-- Note: We set 'Alignment and check for 'Size.
end S;
2018-05-22 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* freeze.adb (Freeze_Entity): When analyzing delayed aspects of an
entity E within a generic unit, indicate that there are no remaining
delayed aspects after invoking Analyze_Aspects_At_Freeze_Point. The
entity E is not frozen yet but the aspects should not be reanalyzed at
the freeze point, which may be outside of the generic and may not have
the proper visibility.
From-SVN: r260516
-rw-r--r-- | gcc/ada/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/freeze.adb | 5 |
2 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ad65479..378ccad 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2018-05-22 Ed Schonberg <schonberg@adacore.com> + + * freeze.adb (Freeze_Entity): When analyzing delayed aspects of an + entity E within a generic unit, indicate that there are no remaining + delayed aspects after invoking Analyze_Aspects_At_Freeze_Point. The + entity E is not frozen yet but the aspects should not be reanalyzed at + the freeze point, which may be outside of the generic and may not have + the proper visibility. + 2018-05-22 Bob Duff <duff@adacore.com> * doc/gnat_ugn/gnat_utility_programs.rst: Add documentation for diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index da77818..66f9dcc 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -5167,11 +5167,14 @@ package body Freeze is -- be frozen in the proper scope after the current generic is analyzed. -- However, aspects must be analyzed because they may be queried later -- within the generic itself, and the corresponding pragma or attribute - -- definition has not been analyzed yet. + -- definition has not been analyzed yet. After this, indicate that the + -- entity has no further delayed aspects, to prevent a later aspect + -- analysis out of the scope of the generic. elsif Inside_A_Generic and then External_Ref_In_Generic (Test_E) then if Has_Delayed_Aspects (E) then Analyze_Aspects_At_Freeze_Point (E); + Set_Has_Delayed_Aspects (E, False); end if; Result := No_List; |