[Ada] fix bug in handling of visibility
Arnaud Charlet
charlet@adacore.com
Thu Feb 10 18:57:00 GMT 2005
Tested under i686-linux, commited on mainline.
If package P declares a private type T, and a child unit of P declares
ST as a subtype of T, then in the body the child unit ST is non-private
and its full view is available. The exchange of private and full views
of ST is done on entrance and exit from the compilation of the child
unit, by traversing the list of Private_Dependents of the parent type T.
If this traversal is done after exchanging the views of T itself on entry
to the package, on exit it must be done before the reverse exchange.
test case, must compile quietly:
--
package body Low_Level_Types.Operations is
procedure Process_A (A : LL_Array_Abstraction) is begin null; end;
procedure Process_I (I : LL_Integer_Abstraction) is begin null; end;
end;
package Low_Level_Types.Operations is
procedure Process_A (A : LL_Array_Abstraction);
procedure Process_I (I : LL_Integer_Abstraction);
end;
package Low_Level_Types is
type LL_Array_Abstraction is private;
type LL_Integer_Abstraction is private;
private
type Array_Type is array (1 .. 4) of Character;
type LL_Array_Abstraction is new Array_Type;
type LL_Integer_Abstraction is new Integer;
end;
with User_Types; use User_types;
with Low_Level_Types.Operations; use Low_Level_Types.Operations;
procedure User_Code is
A : U_Array_Abstraction; I : U_Integer_Abstraction;
begin
Process_I (I); Process_A (A);
end;
with Low_Level_Types;
package User_Types is
subtype U_Array_Abstraction is Low_Level_Types.LL_Array_Abstraction;
subtype U_Integer_Abstraction is Low_Level_Types.LL_Integer_Abstraction;
end;
--
2005-02-09 Ed Schonberg <schonberg@adacore.com>
* sem_ch7.adb (Uninstall_Declarations): Exchange full and private
views of a private type after handling its private dependents, to
maintain proper stack discipline between entry and exit from the
package.
-------------- next part --------------
Index: sem_ch7.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/sem_ch7.adb,v
retrieving revision 1.19
diff -u -p -r1.19 sem_ch7.adb
--- sem_ch7.adb 8 Dec 2004 11:49:39 -0000 1.19
+++ sem_ch7.adb 10 Feb 2005 11:48:16 -0000
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -1905,7 +1905,6 @@ package body Sem_Ch7 is
end if;
Priv_Elmt := First_Elmt (Private_Dependents (Id));
- Exchange_Declarations (Id);
-- Swap out the subtypes and derived types of Id that were
-- compiled in this scope, or installed previously by
@@ -1937,6 +1936,10 @@ package body Sem_Ch7 is
Next_Elmt (Priv_Elmt);
end loop;
+ -- Now restore the type itself to its private view.
+
+ Exchange_Declarations (Id);
+
elsif Ekind (Id) = E_Incomplete_Type
and then No (Full_View (Id))
then
More information about the Gcc-patches
mailing list