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] Crash on illegal discrete range


With this patch the compiler rejects properly a discrete range in a loop
specification that uses 'length by mistake.

Compiler lab4.adb must yield:

   lab4.adb:13:23: expect attribute "range"

---
package body lab4 is
   procedure createArray (myArr : in out dynArray; maxIndex : Integer) is
      tempArr : dynArray (1..maxIndex);
      cntArr : integer :=0;
   begin
      for i in tempArr'length loop
         tempArr(cntArr):= cntArr;
         cntArr := cntArr+1;
      end loop;
   end createArray;
end lab4;
---
package lab4 is
   Type Node;
   Type Tree is access Node;

   Type Node is record
      Val : Integer;
      Left, Right : Tree;
   end record;

   type dynArray is array (positive range <>) of Integer; -- typeset for array

   procedure createArray (myArr : in out dynArray; maxIndex : Integer);
end lab4;

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

2014-07-31  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Make_Index): Reject properly the use of 'Length
	in a discrete range, when 'range was probably intended.

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]