2013-07-08 Robert Dewar <dewar@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Jul 2013 08:11:50 +0000 (08:11 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Jul 2013 08:11:50 +0000 (08:11 +0000)
* gnat_rm.texi: Add documentation for Img returning a function.
* par-prag.adb: Minor reformatting.
* restrict.adb: Minor reformatting and code reorganization.

2013-07-08  Ed Schonberg  <schonberg@adacore.com>

* sem_res.adb: add guard to ASIS transform.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200769 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gnat_rm.texi
gcc/ada/par-prag.adb
gcc/ada/restrict.adb
gcc/ada/sem_res.adb

index a463f6a..0ce9b2e 100644 (file)
@@ -1,3 +1,13 @@
+2013-07-08  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_rm.texi: Add documentation for Img returning a function.
+       * par-prag.adb: Minor reformatting.
+       * restrict.adb: Minor reformatting and code reorganization.
+
+2013-07-08  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_res.adb: add guard to ASIS transform.
+
 2013-07-08  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_ch9.adb (Expand_N_Asynchronous_Select): If the trigger
index 89db117..85bc98f 100644 (file)
@@ -8057,8 +8057,8 @@ indicates whether or not the corresponding actual type has discriminants.
 @unnumberedsec Attribute Img
 @findex Img
 @noindent
-The @code{Img} attribute differs from @code{Image} in that it may be
-applied to objects as well as types, in which case it gives the
+The @code{Img} attribute differs from @code{Image} in that it is applied
+directly to an object, and yields the same result as
 @code{Image} for the subtype of the object.  This is convenient for
 debugging:
 
@@ -8076,6 +8076,12 @@ Put_Line ("X = " & @var{T}'Image (X));
 @noindent
 where @var{T} is the (sub)type of the object @code{X}.
 
+Note that technically, in analogy to @code{Image},
+@code{X'Img} returns a parameterless function
+that returns the appropriate string when called. This means that
+@code{X'Img} can be renamed as a function-returning-string, or used
+in an instantiation as a function parameter.
+
 @node Attribute Integer_Value
 @unnumberedsec Attribute Integer_Value
 @findex Integer_Value
index 762f433..4d01db0 100644 (file)
@@ -232,10 +232,8 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
          Id := Chars (Arg);
          Expr := Expression (Arg);
 
-         if Id = No_Name
-           and then Nkind (Expr) = N_Identifier
-         then
-            case  Chars (Expr) is
+         if Id = No_Name and then Nkind (Expr) = N_Identifier then
+            case Chars (Expr) is
                when Name_No_Obsolescent_Features =>
                   Set_Restriction (No_Obsolescent_Features, Pragma_Node);
                   Restriction_Warnings (No_Obsolescent_Features) :=
index f78236a..a90cf1a 100644 (file)
@@ -1171,20 +1171,16 @@ package body Restrict is
 
    function Same_Unit (U1, U2 : Node_Id) return Boolean is
    begin
-      if Nkind (U1) = N_Identifier then
-         return Nkind (U2) = N_Identifier and then Chars (U1) = Chars (U2);
+      if Nkind (U1) = N_Identifier and then Nkind (U2) = N_Identifier then
+         return Chars (U1) = Chars (U2);
 
-      elsif Nkind (U2) = N_Identifier then
-         return False;
-
-      elsif (Nkind (U1) = N_Selected_Component
-             or else Nkind (U1) = N_Expanded_Name)
-        and then
-          (Nkind (U2) = N_Selected_Component
-           or else Nkind (U2) = N_Expanded_Name)
+      elsif Nkind_In (U1, N_Selected_Component, N_Expanded_Name)
+              and then
+            Nkind_In (U2, N_Selected_Component, N_Expanded_Name)
       then
          return Same_Unit (Prefix (U1), Prefix (U2))
-           and then Same_Unit (Selector_Name (U1), Selector_Name (U2));
+                  and then
+                Same_Unit (Selector_Name (U1), Selector_Name (U2));
       else
          return False;
       end if;
index 9b26f09..61f7712 100644 (file)
@@ -1578,9 +1578,10 @@ package body Sem_Res is
       end if;
 
       --  If in ASIS_Mode, propagate operand types to original actuals of
-      --  function call, which would otherwise not be fully resolved.
+      --  function call, which would otherwise not be fully resolved. If
+      --  the call has already been constant-folded, nothing to do.
 
-      if ASIS_Mode then
+      if ASIS_Mode and then Nkind (N) in N_Op then
          if Is_Binary then
             Set_Parameter_Associations
               (Original_Node (N),