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] |
If the range of iteration in an Ada2012 iterator is a function call returning a container, finalization actions will in general be created because the predefined containers are controlled. The finalization actions must be taken into account when rewriting the iteration as a while-loop. Compiling and executing the following in Ada2012 mode must yield: 12345 --- with Ada.Containers.Ordered_Sets; with Text_IO; use Text_IO; procedure T is function Hash (X : integer) return integer is begin return X / 2; end; package Integer_Sets is new Ada.Containers.Ordered_Sets (Element_Type => Integer); function P return Integer_Sets.Set; function P return Integer_Sets.Set is use Integer_Sets; result : Set := Empty_Set; begin Result.Insert (12345); return Result; end P; begin for Element of P loop Put_Line (Integer'Image (Element)); end loop; end T; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-02 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb (Analyze_Iteration_Scheme): For an Ada2012 iterator with "of", pre-analyze expression in case it is a function call with finalization actions that must be placed ahead of the loop. * exp_ch5.adb (Expand_Iterator_Loop): If condition_actions are present on an Ada2012 iterator, insert them ahead of the rewritten loop.
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] |