comp.lang.ada
 help / color / mirror / Atom feed
* Labeled exit within generalized labeled loop not allowed?
@ 2012-07-13 16:19 Marc C
  2012-07-13 17:21 ` Thomas Løcke
  2012-07-16  9:33 ` Thomas Løcke
  0 siblings, 2 replies; 9+ messages in thread
From: Marc C @ 2012-07-13 16:19 UTC (permalink / raw)


I find it hard to believe that this would be a GNAT GPL 2012 compiler bug, but I don't see anything in the LRM that indicates this wouldn't be legal.

Code containing a labeled generalized loop (the "for Elem of Some_Container" type), with a conditional exit referencing the loop label, fails to compile with an "Invalid loop name in exit statement" error.

What's the rationale for this? Or a consequence of what? Or is it a compiler bug?

Marc A. Criley

Here's an example:

with Text_IO; use Text_IO;

procedure Loop_Check is

   type Int_Array_Type is array (1..10) of Integer;
   
   IA : Int_Array_Type := (6 => 6, others => 3);
   
begin
   Loop_A: For I in IA'range loop
      Put_Line(Integer'Image(IA(I)));
      exit Loop_A When IA(I) = 6;
   end loop Loop_A;
   
   Loop_B: For I of IA loop
      Put_Line(Integer'Image(I));
      exit when I = 6;
   end loop Loop_B;
   
   Loop_C: For I of IA loop
      Put_Line(Integer'Image(I));
      exit Loop_C when I = 6; -- Compiler error on this line
   end loop Loop_C;
end Loop_Check;



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-07-25  3:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-13 16:19 Labeled exit within generalized labeled loop not allowed? Marc C
2012-07-13 17:21 ` Thomas Løcke
2012-07-16  9:33 ` Thomas Løcke
2012-07-16 10:33   ` Niklas Holsti
2012-07-16 12:03     ` Niklas Holsti
2012-07-16 12:29       ` Thomas Løcke
2012-07-16 15:24         ` Marc C
2012-07-17  6:01           ` Thomas Løcke
2012-07-19  6:41       ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox