]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 9 Mar 2012 14:54:58 +0000 (15:54 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 9 Mar 2012 14:54:58 +0000 (15:54 +0100)
2012-03-09  Vasiliy Fofanov  <fofanov@adacore.com>

* a-direct.adb: Do not strip the trailing directory separator
from path, as this is already done inside Normalize_Pathname;
doing it again produces the wrong result on Windows for the
drive's root dir (i.e. "X:\" becomes "X:").

2012-03-09  Thomas Quinot  <quinot@adacore.com>

* exp_attr.adb, freeze.adb, sem_attr.adb, aspects.adb, aspects.ads,
sem_ch13.adb, snames.ads-tmpl (Exp_Attr.Expand_N_Attribute_Reference):
Add Attribute_Scalar_Storage_Order.
(Sem_Attr.Analyze_Attribute, Eval_Attribute): Ditto.
(Aspects): Add Aspect_Scalar_Storage_Order (Snames): Add
Name_Scalar_Storage_Order and Attribute_Scalar_Storage_Order.
(Sem_Ch13.Analyze_Attribute_Definition_Clause): Add processing
for Scalar_Storage_Order.
(Freeze): If Scalar_Storage_Order is specified, check that it
is compatible with Bit_Order.

From-SVN: r185142

gcc/ada/ChangeLog
gcc/ada/a-direct.adb
gcc/ada/aspects.adb
gcc/ada/aspects.ads
gcc/ada/exp_attr.adb
gcc/ada/freeze.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_ch13.adb
gcc/ada/snames.ads-tmpl

index fdb14ddcb9ce5b5853624244c0bf8f8e45b0e214..90f87ddf670c67e43ef0c61b9cdabdf93824ca63 100644 (file)
@@ -1,3 +1,23 @@
+2012-03-09  Vasiliy Fofanov  <fofanov@adacore.com>
+
+       * a-direct.adb: Do not strip the trailing directory separator
+       from path, as this is already done inside Normalize_Pathname;
+       doing it again produces the wrong result on Windows for the
+       drive's root dir (i.e. "X:\" becomes "X:").
+
+2012-03-09  Thomas Quinot  <quinot@adacore.com>
+
+       * exp_attr.adb, freeze.adb, sem_attr.adb, aspects.adb, aspects.ads,
+       sem_ch13.adb, snames.ads-tmpl (Exp_Attr.Expand_N_Attribute_Reference):
+       Add Attribute_Scalar_Storage_Order.
+       (Sem_Attr.Analyze_Attribute, Eval_Attribute): Ditto.
+       (Aspects): Add Aspect_Scalar_Storage_Order (Snames): Add
+       Name_Scalar_Storage_Order and Attribute_Scalar_Storage_Order.
+       (Sem_Ch13.Analyze_Attribute_Definition_Clause): Add processing
+       for Scalar_Storage_Order.
+       (Freeze): If Scalar_Storage_Order is specified, check that it
+       is compatible with Bit_Order.
+
 2012-03-09  Robert Dewar  <dewar@adacore.com>
 
        * s-osinte-linux.ads, sem_util.adb, s-taprop-linux.adb, exp_ch4.adb,
index e27bb3fdd6d8c3c7a9a9c772109242630170b60b..88e1d72078f07a24aaf862e542b94987e5493669 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2004-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 2004-2012, 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- --
@@ -514,18 +514,10 @@ package body Ada.Directories is
    begin
       Local_Get_Current_Dir (Buffer'Address, Path_Len'Address);
 
-      declare
-         --  We need to resolve links because of A.16(47), since we must not
-         --  return alternative names for files
-         Cur : constant String := Normalize_Pathname (Buffer (1 .. Path_Len));
+      --  We need to resolve links because of A.16(47), since we must not
+      --  return alternative names for files
+      return Normalize_Pathname (Buffer (1 .. Path_Len));
 
-      begin
-         if Cur'Length > 1 and then Cur (Cur'Last) = Dir_Separator then
-            return Cur (1 .. Cur'Last - 1);
-         else
-            return Cur;
-         end if;
-      end;
    end Current_Directory;
 
    ----------------------
index 89af1d975f3fc8947b5923ac4e1ac7d95ce0459a..51f468c7889d47da64c7d230cec31241806b805b 100755 (executable)
@@ -278,6 +278,7 @@ package body Aspects is
     Aspect_Pure_12                      => Aspect_Pure_12,
     Aspect_Remote_Call_Interface        => Aspect_Remote_Call_Interface,
     Aspect_Remote_Types                 => Aspect_Remote_Types,
+    Aspect_Scalar_Storage_Order         => Aspect_Scalar_Storage_Order,
     Aspect_Shared_Passive               => Aspect_Shared_Passive,
     Aspect_Universal_Data               => Aspect_Universal_Data,
     Aspect_Input                        => Aspect_Input,
index 3c28af83b8f1452fa7e28f24d0f80d4b93e90dc5..84548a9d20d483af5e3a57ac16669d03ac624697 100755 (executable)
@@ -74,6 +74,7 @@ package Aspects is
       Aspect_Predicate,                     -- GNAT
       Aspect_Priority,
       Aspect_Read,
+      Aspect_Scalar_Storage_Order,          -- GNAT
       Aspect_Simple_Storage_Pool,           -- GNAT
       Aspect_Size,
       Aspect_Small,
@@ -188,6 +189,7 @@ package Aspects is
                              Aspect_Pure_Function            => True,
                              Aspect_Remote_Access_Type       => True,
                              Aspect_Shared                   => True,
+                             Aspect_Scalar_Storage_Order     => True,
                              Aspect_Simple_Storage_Pool      => True,
                              Aspect_Simple_Storage_Pool_Type => True,
                              Aspect_Suppress_Debug_Info      => True,
@@ -281,6 +283,7 @@ package Aspects is
                         Aspect_Predicate               => Expression,
                         Aspect_Priority                => Expression,
                         Aspect_Read                    => Name,
+                        Aspect_Scalar_Storage_Order    => Expression,
                         Aspect_Simple_Storage_Pool     => Name,
                         Aspect_Size                    => Expression,
                         Aspect_Small                   => Expression,
@@ -367,6 +370,7 @@ package Aspects is
      Aspect_Remote_Access_Type           => Name_Remote_Access_Type,
      Aspect_Remote_Call_Interface        => Name_Remote_Call_Interface,
      Aspect_Remote_Types                 => Name_Remote_Types,
+     Aspect_Scalar_Storage_Order         => Name_Scalar_Storage_Order,
      Aspect_Shared                       => Name_Shared,
      Aspect_Shared_Passive               => Name_Shared_Passive,
      Aspect_Simple_Storage_Pool          => Name_Simple_Storage_Pool,
index 7621ff75e75fb5e81df2517204aa591120b6a478..4f67ef97dce50796c6c3c5226fea871181da07d5 100644 (file)
@@ -5672,7 +5672,8 @@ package body Exp_Attr is
            Attribute_Definite                     |
            Attribute_Null_Parameter               |
            Attribute_Passed_By_Reference          |
-           Attribute_Pool_Address                 =>
+           Attribute_Pool_Address                 |
+           Attribute_Scalar_Storage_Order         =>
          null;
 
       --  The following attributes are also handled by the back end, but return
index 15bd6e075e3adfe2bc9e6735612a57831160ad55..51e87acfa2518d585e086139ffd90c731f56ef90 100644 (file)
@@ -2129,6 +2129,28 @@ package body Freeze is
             Next_Entity (Comp);
          end loop;
 
+         --  Check compatibility of Scalar_Storage_Order with Bit_Order, if the
+         --  former is specified.
+
+         ADC := Get_Attribute_Definition_Clause
+                  (Rec, Attribute_Scalar_Storage_Order);
+
+         if Present (ADC)
+              and then
+            Reverse_Bit_Order (Rec) /= Reverse_Storage_Order (Rec)
+         then
+            if Bytes_Big_Endian = not Reverse_Storage_Order (Rec) then
+               Error_Msg_N
+                 ("Scalar_Storage_Order High_Order_First is inconsistent with"
+                  & " Bit_Order", ADC);
+            else
+               Error_Msg_N
+                 ("Scalar_Storage_Order Low_Order_First is inconsistent with"
+                  & " Bit_Order", ADC);
+
+            end if;
+         end if;
+
          --  Deal with Bit_Order aspect specifying a non-default bit order
 
          if Reverse_Bit_Order (Rec) and then Base_Type (Rec) = Rec then
index a2b33d8bceb1e4cfae20a672312abd66ad5a666e..3df48228deadf3cad614eb4c108cd6dacb4ae5e5 100644 (file)
@@ -4442,6 +4442,35 @@ package body Sem_Attr is
          Check_Object_Reference (E1);
          Set_Etype (N, Standard_Boolean);
 
+      --------------------------
+      -- Scalar_Storage_Order --
+      --------------------------
+
+      when Attribute_Scalar_Storage_Order => Scalar_Storage_Order :
+      begin
+         Check_E0;
+         Check_Type;
+
+         if not Is_Record_Type (P_Type) then
+            Error_Attr_P ("prefix of % attribute must be record type");
+         end if;
+
+         if Bytes_Big_Endian xor Reverse_Storage_Order (P_Type) then
+            Rewrite (N,
+              New_Occurrence_Of (RTE (RE_High_Order_First), Loc));
+         else
+            Rewrite (N,
+              New_Occurrence_Of (RTE (RE_Low_Order_First), Loc));
+         end if;
+
+         Set_Etype (N, RTE (RE_Bit_Order));
+         Resolve (N);
+
+         --  Reset incorrect indication of staticness
+
+         Set_Is_Static_Expression (N, False);
+      end Scalar_Storage_Order;
+
       -----------
       -- Scale --
       -----------
@@ -7963,6 +7992,7 @@ package body Sem_Attr is
            Attribute_Priority                   |
            Attribute_Read                       |
            Attribute_Result                     |
+           Attribute_Scalar_Storage_Order       |
            Attribute_Simple_Storage_Pool        |
            Attribute_Storage_Pool               |
            Attribute_Storage_Size               |
index 9e552ec1118e324a7f1a43af10146fbf631e432c..2a9255849680f607022d99ba1d311d3d7268bf0d 100644 (file)
@@ -1064,24 +1064,25 @@ package body Sem_Ch13 is
 
                --  Aspects corresponding to attribute definition clauses
 
-               when Aspect_Address             |
-                    Aspect_Alignment           |
-                    Aspect_Bit_Order           |
-                    Aspect_Component_Size      |
-                    Aspect_External_Tag        |
-                    Aspect_Input               |
-                    Aspect_Machine_Radix       |
-                    Aspect_Object_Size         |
-                    Aspect_Output              |
-                    Aspect_Read                |
-                    Aspect_Size                |
-                    Aspect_Small               |
-                    Aspect_Simple_Storage_Pool |
-                    Aspect_Storage_Pool        |
-                    Aspect_Storage_Size        |
-                    Aspect_Stream_Size         |
-                    Aspect_Value_Size          |
-                    Aspect_Write               =>
+               when Aspect_Address              |
+                    Aspect_Alignment            |
+                    Aspect_Bit_Order            |
+                    Aspect_Component_Size       |
+                    Aspect_External_Tag         |
+                    Aspect_Input                |
+                    Aspect_Machine_Radix        |
+                    Aspect_Object_Size          |
+                    Aspect_Output               |
+                    Aspect_Read                 |
+                    Aspect_Scalar_Storage_Order |
+                    Aspect_Size                 |
+                    Aspect_Small                |
+                    Aspect_Simple_Storage_Pool  |
+                    Aspect_Storage_Pool         |
+                    Aspect_Storage_Size         |
+                    Aspect_Stream_Size          |
+                    Aspect_Value_Size           |
+                    Aspect_Write                =>
 
                   --  Construct the attribute definition clause
 
@@ -2989,6 +2990,40 @@ package body Sem_Ch13 is
             Analyze_Stream_TSS_Definition (TSS_Stream_Read);
             Set_Has_Specified_Stream_Read (Ent);
 
+         --------------------------
+         -- Scalar_Storage_Order --
+         --------------------------
+
+         --  Scalar_Storage_Order attribute definition clause
+
+         when Attribute_Scalar_Storage_Order => Scalar_Storage_Order : declare
+         begin
+            if not Is_Record_Type (U_Ent) then
+               Error_Msg_N
+                 ("Scalar_Storage_Order can only be defined for record type",
+                  Nam);
+
+            elsif Duplicate_Clause then
+               null;
+
+            else
+               Analyze_And_Resolve (Expr, RTE (RE_Bit_Order));
+
+               if Etype (Expr) = Any_Type then
+                  return;
+
+               elsif not Is_Static_Expression (Expr) then
+                  Flag_Non_Static_Expr
+                    ("Scalar_Storage_Order requires static expression!", Expr);
+
+               else
+                  if (Expr_Value (Expr) = 0) /= Bytes_Big_Endian then
+                     Set_Reverse_Storage_Order (U_Ent, True);
+                  end if;
+               end if;
+            end if;
+         end Scalar_Storage_Order;
+
          ----------
          -- Size --
          ----------
@@ -6147,7 +6182,7 @@ package body Sem_Ch13 is
          when Aspect_Address =>
             T := RTE (RE_Address);
 
-         when Aspect_Bit_Order =>
+         when Aspect_Bit_Order | Aspect_Scalar_Storage_Order =>
             T := RTE (RE_Bit_Order);
 
          when Aspect_CPU =>
index cce46080d0a75efd2abe9b82ceca77f3a044b590..26cb3d9b605b3b3046dad9040cd55b3ac2537194 100644 (file)
@@ -120,7 +120,7 @@ package Snames is
    Name_uY : constant Name_Id := First_Name_Id + Character'Pos ('Y');
    Name_uZ : constant Name_Id := First_Name_Id + Character'Pos ('Z');
 
-   --  Note: the following table is read by the utility program XSNAMES and
+   --  Note: the following table is read by the utility program XSNAMES, and
    --  its format should not be changed without coordinating with this program.
 
    N : constant Name_Id := First_Name_Id + 256;
@@ -826,6 +826,7 @@ package Snames is
    Name_Safe_Last                      : constant Name_Id := N + $;
    Name_Safe_Small                     : constant Name_Id := N + $; -- Ada 83
    Name_Same_Storage                   : constant Name_Id := N + $; -- Ada 12
+   Name_Scalar_Storage_Order           : constant Name_Id := N + $; -- GNAT
    Name_Scale                          : constant Name_Id := N + $;
    Name_Scaling                        : constant Name_Id := N + $;
    Name_Signed_Zeros                   : constant Name_Id := N + $;
@@ -1387,6 +1388,7 @@ package Snames is
       Attribute_Safe_Last,
       Attribute_Safe_Small,
       Attribute_Same_Storage,
+      Attribute_Scalar_Storage_Order,
       Attribute_Scale,
       Attribute_Scaling,
       Attribute_Signed_Zeros,