This patch adds another condition to an edge case used to delay expression
function freezing (P804-015). The offending package is within the body of a
library-level unit where this edge-case does not apply. By adding a condition
that only delays freezing of expression functions if we are in a library-level
spec we can avoid spurious disambiguation errors.
------------
-- Source --
------------
-- pkg.ads
package Pkg is
pragma Elaborate_Body;
end;
-- pkg.adb
with Ada.Containers.Vectors;
package body Pkg is
package SubPkg1 is
type T1 is private;
function Foo (T : T1) return Boolean is (True);
subtype ST1 is T1 with Dynamic_Predicate => Foo (ST1);
private
type T1 is null record;
end;
package SubPkg2 is
type T2 is private;
function Foo (T : T2) return Boolean is (True);
private
package V2 is new Ada.Containers.Vectors
(Positive, SubPkg1.ST1, SubPkg1."=");
type T2 is record
SubPkg1 : V2.Vector;
end record;
end;
type C is record
Count : Natural;
end record;
type CA is array (1 .. 3) of C;
package VC is new Ada.Containers.Vectors (Positive, CA);
V : VC.Vector;
procedure Bar is
begin
for P in V.Iterate loop
for X of V (P) loop
X.Count := X.Count - 1;
end loop;
end loop;
end;
end;
----------------------------
-- Compilation and output --
----------------------------
$ gcc -c pkg.adb
pkg.adb:15:07: warning: in instantiation at a-convec.ads:375
pkg.adb:15:07: warning: component of "Elements_Array" padded by 8 bits
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-04-25 Justin Squirek <[email protected]>
* sem_ch3.adb (Analyze_Declarations): Add
additional condition for edge case.
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb (revision 247146)
+++ sem_ch3.adb (working copy)
@@ -2646,6 +2646,8 @@
and then Was_Expression_Function (Next_Decl)
and then not Is_Compilation_Unit (Current_Scope)
and then not Is_Generic_Instance (Current_Scope)
+ and then not In_Package_Body
+ (Enclosing_Lib_Unit_Entity (Current_Scope))
then
-- Loop through all entities in the current scope to identify
-- an instance of the edge case outlined above and ignore