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] Check violation of 6.20/3 in aggregates


This patch extends the machinery which detects dangerous order
dependencies caused by out-mode parameters of Ada 2012 functions
(AI-0144) to detect the error in array aggregates that have a
nonstatic range (RM 6.20/3).

The compiler now catches the error in the following sources:

pragma Ada_2012;
procedure test_aggr is

   function f (a : in out Integer) return Integer is
   begin
      a := 2 * a;
      return a;
   end;

   type Arr is array (Natural range <>)  of Integer;

   procedure Proc (A : Arr)  is
   begin
      null;
   end;

   I               : Integer := 0;
   Nonstatic_Bound : Integer := F (I);

begin
   I := F (I);
   --  Ensure that the compiler does not handle I as constant

   Proc ((1 .. I => F (I)));                -- ERROR
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2015-05-26  Javier Miranda  <miranda@adacore.com>

	* sem_util.adb (Check_Function_Writable_Actuals):
	Add missing support to check the violation of writable actuals
	in array aggregates that have a nonstatic range.

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]