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] Subprograms should not be treated as Pure if limited arguments


This patch corrects the oversight of not implementing the restriction
in the RM that calls to Pure subprograms cannot be eliminated if one
or more of the arguments is limited. The fix is to reset the Is_Pure
flag on affected subprogram entities.

The following test program:

package PureLimited is
   pragma Pure;
   type r is limited null record;
   function f1 (x : integer) return integer;
   function f2 (x : r) return integer;
end;

package body PureLimited is
   function f1 (x : integer) return integer
   is
   begin
      return 1;
   end;

   function f2 (x : r) return integer
   is
   begin
      return 1;
   end;
end;

compiled with -gnatdt >log generates a log file which when
processed with grep Is_Pure log outputs:

    |    Is_Pure = True

Prior to the patch, two lines were output

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

2010-09-10  Robert Dewar  <dewar@adacore.com>

	* exp_ch6.adb (Expand_N_Subprogram_Body): Reset Is_Pure if limited
	arguments.

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]