]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sem_ch5.adb (Analyze_Loop_Parameter_Specification): If the domain of iteration is...
authorEd Schonberg <schonberg@adacore.com>
Mon, 24 Feb 2014 16:56:25 +0000 (16:56 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 24 Feb 2014 16:56:25 +0000 (17:56 +0100)
2014-02-24  Ed Schonberg  <schonberg@adacore.com>

* sem_ch5.adb (Analyze_Loop_Parameter_Specification): If the
domain of iteration is an attribute reference 'Old, this is an
Ada 2012 iterator and the loop must be rewritten as such.

From-SVN: r208080

gcc/ada/ChangeLog
gcc/ada/sem_ch5.adb

index e31ec1edf7ba13168bdd25541d62d2aca30fe220..126bce34b0549835f3fe121635f714017d09cde5 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-24  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch5.adb (Analyze_Loop_Parameter_Specification): If the
+       domain of iteration is an attribute reference 'Old, this is an
+       Ada 2012 iterator and the loop must be rewritten as such.
+
 2014-02-24  Thomas Quinot  <quinot@adacore.com>
 
        * s-fileio.adb (Errno_Message): Remove, use shared version from
index 2126f7064091cded57c7a37def4fb7a72989d366..ead28bff0ac7313ccdadfad71b70d94fdf24076f 100644 (file)
@@ -2362,12 +2362,21 @@ package body Sem_Ch5 is
          Set_Parent (DS_Copy, Parent (DS));
          Preanalyze_Range (DS_Copy);
 
-         --  Ada 2012: If the domain of iteration is a function call, it is the
-         --  new iterator form.
+         --  Ada 2012: If the domain of iteration is:
+
+         --  a)  a function call,
+         --  b)  an identifier that is not a type,
+         --  c)  an attribute reference 'Old (within a postcondition)
+
+         --  then it is an iteration over a container. It was classified as
+         --  a loop specification by the parser, and must be rewritten now
+         --  to activate container iteration.
 
          if Nkind (DS_Copy) = N_Function_Call
            or else (Is_Entity_Name (DS_Copy)
                      and then not Is_Type (Entity (DS_Copy)))
+           or else (Nkind (DS_Copy) = N_Attribute_Reference
+             and then Attribute_Name (DS_Copy) = Name_Old)
          then
             --  This is an iterator specification. Rewrite it as such and
             --  analyze it to capture function calls that may require