This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Spurious compile failure with nested packages


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  <squirek@adacore.com>

	* sem_ch3.adb (Analyze_Declarations): Add
	additional condition for edge case.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]