]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 4 Feb 2014 14:49:39 +0000 (15:49 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 4 Feb 2014 14:49:39 +0000 (15:49 +0100)
2014-02-04  Gary Dismukes  <dismukes@adacore.com>

* sem_aggr.adb: Change "runtime" to "run time" in warning message,
for consistency with other messages.

2014-02-04  Ed Schonberg  <schonberg@adacore.com>

* exp_ch5.adb  (Expand_Iterator_Loop):  For a container element
iterator, indicate that the element is a constant if the container
type does not have a variable indexing aspect.
* sem_ch8.adb (Analyze_Object_Renaming): If the entity is already
marked as constant, do not reset its Ekind, to ensure that
container elements in an element loop are not modified if the
container (e.g. a hashed set) only has a constant indexing aspect.

2014-02-04  Arnaud Charlet  <charlet@adacore.com>

* g-souinf.ads: Subprograms in this unit are actually not pure.
* freeze.adb (Freeze_Subprogram): Do not reset Is_Pure for Intrinsics.
* einfo.ads (Is_Pure): Update doc to match implementation.

From-SVN: r207469

gcc/ada/ChangeLog
gcc/ada/einfo.ads
gcc/ada/exp_ch5.adb
gcc/ada/freeze.adb
gcc/ada/g-souinf.ads
gcc/ada/sem_aggr.adb
gcc/ada/sem_ch8.adb

index cab52638c8d448ebbdc527278c27752ec072b023..8f43cfe9de6467ffb37c956a7ff72a2482c41c49 100644 (file)
@@ -1,3 +1,24 @@
+2014-02-04  Gary Dismukes  <dismukes@adacore.com>
+
+       * sem_aggr.adb: Change "runtime" to "run time" in warning message,
+       for consistency with other messages.
+
+2014-02-04  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_ch5.adb  (Expand_Iterator_Loop):  For a container element
+       iterator, indicate that the element is a constant if the container
+       type does not have a variable indexing aspect.
+       * sem_ch8.adb (Analyze_Object_Renaming): If the entity is already
+       marked as constant, do not reset its Ekind, to ensure that
+       container elements in an element loop are not modified if the
+       container (e.g. a hashed set) only has a constant indexing aspect.
+
+2014-02-04  Arnaud Charlet  <charlet@adacore.com>
+
+       * g-souinf.ads: Subprograms in this unit are actually not pure.
+       * freeze.adb (Freeze_Subprogram): Do not reset Is_Pure for Intrinsics.
+       * einfo.ads (Is_Pure): Update doc to match implementation.
+
 2014-02-04  Gary Dismukes  <dismukes@adacore.com>
 
        * exp_ch13.adb: Minor spelling fix.
index e006455dbc270669cfbf61e56172cfab8607226a..fae25dee0fdc5a7a8f947e486a11acf9c78f578d 100644 (file)
@@ -2775,13 +2775,13 @@ package Einfo is
 
 --    Is_Pure (Flag44)
 --       Defined in all entities. Set in all entities of a unit to which a
---       pragma Pure is applied, and also set for the entity of the unit
---       itself. In addition, this flag may be set for any other functions
---       or procedures that are known to be side effect free, so in the case
---       of subprograms, the Is_Pure flag may be used by the optimizer to
---       imply that it can assume freedom from side effects (other than those
---       resulting from assignment to out parameters, or to objects designated
---       by access parameters).
+--       pragma Pure is applied except for non intrinsic imported subprogram,
+--       and also set for the entity of the unit itself. In addition, this
+--       flag may be set for any other functions or procedures that are known
+--       to be side effect free, so in the case of subprograms, the Is_Pure
+--       flag may be used by the optimizer to imply that it can assume freedom
+--       from side effects (other than those resulting from assignment to out
+--       parameters, or to objects designated by access parameters).
 
 --    Is_Pure_Unit_Access_Type (Flag189)
 --       Defined in access type and subtype entities. Set if the type or
index e563ccf8edc5d66c14c4819f9fa97aa48af2f096..d64d0c82a93ec5fd953c0e1a9e6ab96291a90685 100644 (file)
@@ -3128,6 +3128,15 @@ package body Exp_Ch5 is
 
                Set_Debug_Info_Needed (Id);
 
+               --  If the container does not have a variable indexing aspect,
+               --  the element is a constant in the loop.
+
+               if No (Find_Value_Of_Aspect
+                       (Container_Typ, Aspect_Variable_Indexing))
+               then
+                  Set_Ekind (Id, E_Constant);
+               end if;
+
                --  If the container holds controlled objects, wrap the loop
                --  statements and element renaming declaration with a block.
                --  This ensures that the result of Element (Cusor) is
index 440d562ce5ce57cdc36e3702305a89eb28bdd550..ad74fba927b8eb4f7abee36aca33f19aeadc68b2 100644 (file)
@@ -6514,15 +6514,17 @@ package body Freeze is
       end if;
 
       --  Reset the Pure indication on an imported subprogram unless an
-      --  explicit Pure_Function pragma was present. We do this because
-      --  otherwise it is an insidious error to call a non-pure function from
-      --  pure unit and have calls mysteriously optimized away. What happens
-      --  here is that the Import can bypass the normal check to ensure that
-      --  pure units call only pure subprograms.
+      --  explicit Pure_Function pragma was present or the subprogram is an
+      --  intrinsic. We do this because otherwise it is an insidious error
+      --  to call a non-pure function from pure unit and have calls
+      --  mysteriously optimized away. What happens here is that the Import
+      --  can bypass the normal check to ensure that pure units call only pure
+      --  subprograms.
 
       if Is_Imported (E)
         and then Is_Pure (E)
         and then not Has_Pragma_Pure_Function (E)
+        and then not Is_Intrinsic_Subprogram (E)
       then
          Set_Is_Pure (E, False);
       end if;
index 54c106db9387f1e1238751757dadd02c8cddc915..8810f4db07f3e8902f48112c50688d6b3f86be3b 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                     Copyright (C) 2000-2005 AdaCore                      --
+--          Copyright (C) 2000-2013, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
 --  the name of the source file in which the exception is handled.
 
 package GNAT.Source_Info is
-   pragma Pure;
+   pragma Preelaborate;
+   --  Note that this unit is Preelaborate, but not Pure, that's because the
+   --  functions here such as Line are clearly not pure functions, and normally
+   --  we mark intrinsic functions in a Pure unit as Pure, even though they are
+   --  imported.
+   --
+   --  Historical note: this used to be Pure, but that was when we marked all
+   --  intrinsics as not Pure, even in Pure units, so no problems arose.
 
    function File return String;
    --  Return the name of the current file, not including the path information.
index 504ddcd38be3dcf041d3ed8eba67a1beb47f74ef..6ba4c120ebd99a4ef455794e9776f96087fdd4d9 100644 (file)
@@ -4743,7 +4743,7 @@ package body Sem_Aggr is
          Error_Msg_N
            ("(Ada 2005) null not allowed in null-excluding component??", Expr);
          Error_Msg_N
-           ("\Constraint_Error will be raised at runtime?", Expr);
+           ("\Constraint_Error will be raised at run time?", Expr);
 
          Rewrite (Expr,
            Make_Raise_Constraint_Error
index 773929dcf3ab61e1e6b9d180211e7b67da02b695..da5c6002ac1ebe21cd12bb84258416bb3b2eac77 100644 (file)
@@ -1193,7 +1193,13 @@ package body Sem_Ch8 is
          end;
       end if;
 
-      Set_Ekind (Id, E_Variable);
+      --  Set the Ekind of the entity, unless it has been set already, as is
+      --  the case for the iteration object over a container with no variable
+      --  indexing.
+
+      if Ekind (Id) /= E_Constant then
+         Set_Ekind (Id, E_Variable);
+      end if;
 
       --  Initialize the object size and alignment. Note that we used to call
       --  Init_Size_Align here, but that's wrong for objects which have only