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] Fix error of incorrectly assuming valid in inner subprogram


This patch ensures that when we clear current values, we also reset
Is_Known_Valid. This probably fixes a few problems. The following
test shows one of them. It now raises CE:

P : Positive := 0; -- P'Valid = False

raised CONSTRAINT_ERROR : inval3.adb:21 index check failed

Whereas before it printed Hello World

pragma Initialize_Scalars;
with Text_IO; use Text_IO;
procedure Inval3 is
     pragma Unsuppress (All_Checks);

     Hello_World : constant String := "Hello World!";

     M : String := Hello_World;

     P : Positive := 1;

     procedure Muck (X : out Positive) is
        Uninit : Positive;
     begin
        X := Uninit;
     end Muck;

     procedure Undefined is
     begin
        P := (Integer'First + P) + Integer'Last + 1;
        M (P) := 'J'; -- Where is this 'J' going???
     end Undefined;


begin
     Muck (P);
     Put ("P : Positive :=");
     Put (P'Img);
     Put ("; -- P'Valid = ");
     if P'Valid then
         Put ("True");
     else
         Put ("False");
     end if;
     New_Line;
     Undefined;
     Put (M);
     New_Line;
     Put ("If the above says """ & Hello_World & """"
          & ", where did the 'J' go that we assigned to M?");
     New_Line;
end Inval3;

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

2009-07-27  Robert Dewar  <dewar@adacore.com>

	* sem_util.adb, sem_util.ads (Kill_Current_Values): Reset Is_Known_Valid

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]