[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Thu, 14 Jun 2012 10:49:59 +0000 (12:49 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 14 Jun 2012 10:49:59 +0000 (12:49 +0200)
2012-06-14  Robert Dewar  <dewar@adacore.com>

* exp_ch7.adb, exp_util.adb, sem_aux.ads, exp_ch9.adb,
sem_ch10.adb, freeze.adb, sem_util.adb, exp_ch4.adb,
s-taprop-dummy.adb: Minor reformatting.

2012-06-14  Vincent Pucci  <pucci@adacore.com>

* exp_attr.adb (Expand_N_Attribute_Reference): Lock_Free
attribute case added.
* par-prag.adb (Prag): Lock_Free pragma case added.
* sem_attr.adb (Analyze_Attribute_Reference): Lock_Free attribute
case added.
* sem_ch13.adb (Analyze_Aspect_Specifications): Record_Rep_Item
call added for Aspect_Lock_Free.
* sem_ch9.adb (Allows_Lock_Free_Implementation): New Lock_Free
error messages for subprogram bodies.
(Lock_Free_Disabled): New routine.
(Analyze_Protected_Body): Call to Lock_Free_Disabled added.
* sem_prag.adb (Analyze_Pragma): Lock_Free pragma case added.
* snames.adb-tmpl (Get_Pragma_Id): Name_Lock_Free case added.
(Is_Pragma_Name): Name_Lock_Free case added.
* snames.ads-tmpl: Attribute_Lock_Free and Pragma_Lock_Free added.

2012-06-14  Ed Schonberg  <schonberg@adacore.com>

* a-coorma.adb, a-cborma.adb, a-cbhama.adb, a-ciorma.adb: Add missing
aliased keyword.

2012-06-14  Bob Duff  <duff@adacore.com>

* lib.ads, lib.adb, sem.adb (Write_Unit_Info): Move this
procedure from Sem body to Lib spec, so it can be used for
debugging elsewhere.

2012-06-14  Ed Schonberg  <schonberg@adacore.com>

* sem_ch6.adb (Check_Conformance): Add Ada 2012 check on mode
conformance: "aliased" must apply to both or neither formal
parameters.

From-SVN: r188609

26 files changed:
gcc/ada/ChangeLog
gcc/ada/a-cbhama.adb
gcc/ada/a-cborma.adb
gcc/ada/a-ciorma.adb
gcc/ada/a-coorma.adb
gcc/ada/exp_attr.adb
gcc/ada/exp_ch4.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_ch9.adb
gcc/ada/exp_util.adb
gcc/ada/freeze.adb
gcc/ada/lib.adb
gcc/ada/lib.ads
gcc/ada/par-prag.adb
gcc/ada/s-taprop-dummy.adb
gcc/ada/sem.adb
gcc/ada/sem_attr.adb
gcc/ada/sem_aux.ads
gcc/ada/sem_ch10.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch9.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb
gcc/ada/snames.adb-tmpl
gcc/ada/snames.ads-tmpl

index 3efe1d536d27990d3fa6545a372e0295b52061f7..816d90158bf3c833813296cd1cbe4b20da64b63d 100644 (file)
@@ -1,3 +1,44 @@
+2012-06-14  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch7.adb, exp_util.adb, sem_aux.ads, exp_ch9.adb,
+       sem_ch10.adb, freeze.adb, sem_util.adb, exp_ch4.adb,
+       s-taprop-dummy.adb: Minor reformatting.
+
+2012-06-14  Vincent Pucci  <pucci@adacore.com>
+
+       * exp_attr.adb (Expand_N_Attribute_Reference): Lock_Free
+       attribute case added.
+       * par-prag.adb (Prag): Lock_Free pragma case added.
+       * sem_attr.adb (Analyze_Attribute_Reference): Lock_Free attribute
+       case added.
+       * sem_ch13.adb (Analyze_Aspect_Specifications): Record_Rep_Item
+       call added for Aspect_Lock_Free.
+       * sem_ch9.adb (Allows_Lock_Free_Implementation): New Lock_Free
+       error messages for subprogram bodies.
+       (Lock_Free_Disabled): New routine.
+       (Analyze_Protected_Body): Call to Lock_Free_Disabled added.
+       * sem_prag.adb (Analyze_Pragma): Lock_Free pragma case added.
+       * snames.adb-tmpl (Get_Pragma_Id): Name_Lock_Free case added.
+       (Is_Pragma_Name): Name_Lock_Free case added.
+       * snames.ads-tmpl: Attribute_Lock_Free and Pragma_Lock_Free added.
+
+2012-06-14  Ed Schonberg  <schonberg@adacore.com>
+
+       * a-coorma.adb, a-cborma.adb, a-cbhama.adb, a-ciorma.adb: Add missing
+       aliased keyword.
+
+2012-06-14  Bob Duff  <duff@adacore.com>
+
+       * lib.ads, lib.adb, sem.adb (Write_Unit_Info): Move this
+       procedure from Sem body to Lib spec, so it can be used for
+       debugging elsewhere.
+
+2012-06-14  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch6.adb (Check_Conformance): Add Ada 2012 check on mode
+       conformance: "aliased" must apply to both or neither formal
+       parameters.
+
 2012-06-14  Gary Dismukes  <dismukes@adacore.com>
 
        * exp_ch9.adb: Minor reformatting.
index b14383e321cacec0e5838cd276c04a93c9482eec..8eeaca2e22fb3db84c8a1f67c1992dcfe128fad5 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- --
@@ -220,7 +220,7 @@ package body Ada.Containers.Bounded_Hashed_Maps is
    end Constant_Reference;
 
    function Constant_Reference
-     (Container : Map;
+     (Container : aliased Map;
       Key       : Key_Type) return Constant_Reference_Type
    is
       Node : constant Count_Type := Key_Ops.Find (Container, Key);
index 9dec108219b00b3d2599e2907a93bd3b410acdd1..a782d39af7139d05da97e610d750228a68db4894 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- --
@@ -432,7 +432,7 @@ package body Ada.Containers.Bounded_Ordered_Maps is
    end Constant_Reference;
 
    function Constant_Reference
-     (Container : Map;
+     (Container : aliased Map;
       Key       : Key_Type) return Constant_Reference_Type
    is
       Node : constant Count_Type := Key_Ops.Find (Container, Key);
index b62b87b3a397727fb93ca996d62615fff06f17d2..e955dec891568a944b1de787046ecbcfe19038c6 100644 (file)
@@ -410,7 +410,7 @@ package body Ada.Containers.Indefinite_Ordered_Maps is
    end Constant_Reference;
 
    function Constant_Reference
-     (Container : Map;
+     (Container : aliased Map;
       Key       : Key_Type) return Constant_Reference_Type
    is
       Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
index 0e72d69e315f1e5b6db952824e55f3c388c58504..5aef3636fb0e34658a39a2d4cbff256026ebf13b 100644 (file)
@@ -370,7 +370,7 @@ package body Ada.Containers.Ordered_Maps is
    end Constant_Reference;
 
    function Constant_Reference
-     (Container : Map;
+     (Container : aliased Map;
       Key       : Key_Type) return Constant_Reference_Type
    is
       Node : constant Node_Access := Key_Ops.Find (Container.Tree, Key);
index d63d4dee1ea25813a7118a641438284de0e9f9f0..54ce3ee0baa31386f3587e8d2c6da26d6dff15fa 100644 (file)
@@ -3065,6 +3065,29 @@ package body Exp_Attr is
          end if;
       end;
 
+      ---------------
+      -- Lock_Free --
+      ---------------
+
+      --  Rewrite the attribute reference with the value of Uses_Lock_Free
+
+      when Attribute_Lock_Free => Lock_Free : declare
+         Val : Entity_Id;
+
+      begin
+         if Uses_Lock_Free (Ptyp) then
+            Val := Standard_True;
+
+         else
+            Val := Standard_False;
+         end if;
+
+         Rewrite (N,
+           New_Occurrence_Of (Val, Loc));
+
+         Analyze_And_Resolve (N, Standard_Boolean);
+      end Lock_Free;
+
       -------------
       -- Machine --
       -------------
index fefd6389897a37ca9b829ff6a9d0775668b916d8..5ed4e8afacafc8f99b22e12c7817ec2a89d4a954 100644 (file)
@@ -4277,8 +4277,7 @@ package body Exp_Ch4 is
       --  is a finalization flag created to service expression Expr.
 
       function Is_Controlled_Function_Call (Expr : Node_Id) return Boolean;
-      --  Determine whether an expression is a rewritten controlled function
-      --  call.
+      --  Determine if expression Expr is a rewritten controlled function call
 
       ------------------------
       -- Create_Alternative --
@@ -4431,7 +4430,8 @@ package body Exp_Ch4 is
             --  handling.
 
             if Is_Controlled_Function_Call (Thenx)
-              or else Is_Controlled_Function_Call (Elsex)
+                 or else
+               Is_Controlled_Function_Call (Elsex)
             then
                Flag_Id := Make_Temporary (Loc, 'F');
 
index 4c2af31e7a98b43d9ea4510091fad6c021192cb4..a1d5634bb47a14c724f827414f03e42999a33086 100644 (file)
@@ -1892,14 +1892,13 @@ package body Exp_Ch7 is
                then
                   Processing_Actions (Has_No_Init => True);
 
-               --  Processing for intermediate results of conditional
-               --  expressions where one of the alternatives uses a controlled
-               --  function call.
+               --  Process intermediate results of conditional expression with
+               --  one of the alternatives using a controlled function call.
 
                elsif Is_Access_Type (Obj_Typ)
                  and then Present (Status_Flag_Or_Transient_Decl (Obj_Id))
                  and then Nkind (Status_Flag_Or_Transient_Decl (Obj_Id)) =
-                            N_Defining_Identifier
+                                                       N_Defining_Identifier
                  and then Present (Expr)
                  and then Nkind (Expr) = N_Null
                then
@@ -2728,7 +2727,7 @@ package body Exp_Ch7 is
                --    end if;
 
                if Nkind (Status_Flag_Or_Transient_Decl (Obj_Id)) =
-                    N_Object_Declaration
+                                                      N_Object_Declaration
                then
                   Fin_Stmts := New_List (
                     Make_If_Statement (Loc,
@@ -2736,12 +2735,11 @@ package body Exp_Ch7 is
                         Make_Op_Ne (Loc,
                           Left_Opnd  => New_Reference_To (Obj_Id, Loc),
                           Right_Opnd => Make_Null (Loc)),
-
                       Then_Statements => Fin_Stmts));
 
-               --  Return objects use a flag to aid their potential
-               --  finalization when the enclosing function fails to return
-               --  properly. Generate:
+               --  Return objects use a flag to aid in processing their
+               --  potential finalization when the enclosing function fails
+               --  to return properly. Generate:
 
                --    if not Flag then
                --       <object finalization statements>
index c340baf85d893285f1f4b615a3c093b4139e25a0..dd5a5d59a534e7a9467f649c422085661f7ea0f5 100644 (file)
@@ -13342,7 +13342,7 @@ package body Exp_Ch9 is
          --  or attribute definition clause, or there is an Interrupt_Priority
          --  rep item and no Priority rep item, and we set the ceiling to
          --  Interrupt_Priority'Last, an implementation-defined value, see
-         --  D.3(10).
+         --  (RM D.3(10)).
 
          if Has_Rep_Item (Ptyp, Name_Priority) then
             declare
index 3ebec4f97d00d84d451c73aa033a3e99b93f6794..a732da215c4a0342cbfd30e2567ef9e17bb7b020 100644 (file)
@@ -7181,7 +7181,7 @@ package body Exp_Util is
             elsif Is_Access_Type (Obj_Typ)
               and then Present (Status_Flag_Or_Transient_Decl (Obj_Id))
               and then Nkind (Status_Flag_Or_Transient_Decl (Obj_Id)) =
-                         N_Object_Declaration
+                                                      N_Object_Declaration
               and then Is_Finalizable_Transient
                          (Status_Flag_Or_Transient_Decl (Obj_Id), Decl)
             then
index e58dac5a589437354fd19444c474bc11a4f47312..f0e643d05fed93211dc02381f20a37b2ee75d57d 100644 (file)
@@ -2168,8 +2168,7 @@ package body Freeze is
 
          --  Deal with Bit_Order aspect specifying a non-default bit order
 
-         ADC :=
-           Get_Attribute_Definition_Clause (Rec, Attribute_Bit_Order);
+         ADC := Get_Attribute_Definition_Clause (Rec, Attribute_Bit_Order);
 
          if Present (ADC) and then Base_Type (Rec) = Rec then
             if not Placed_Component then
@@ -2180,7 +2179,7 @@ package body Freeze is
             --  Here is where we do the processing for reversed bit order
 
             elsif Reverse_Bit_Order (Rec)
-                    and then not Reverse_Storage_Order (Rec)
+              and then not Reverse_Storage_Order (Rec)
             then
                Adjust_Record_For_Reverse_Bit_Order (Rec);
 
index 2c5aa4c507ffeab9cb7b7768fc28106544676875..fc62239b29eabf95a9d8b036a4e6f289d5fea3f6 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-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- --
@@ -37,6 +37,7 @@ with Atree;    use Atree;
 with Csets;    use Csets;
 with Einfo;    use Einfo;
 with Fname;    use Fname;
+with Nlists;   use Nlists;
 with Output;   use Output;
 with Sinfo;    use Sinfo;
 with Sinput;   use Sinput;
@@ -1155,4 +1156,82 @@ package body Lib is
       Version_Ref.Append (S);
    end Version_Referenced;
 
+   ---------------------
+   -- Write_Unit_Info --
+   ---------------------
+
+   procedure Write_Unit_Info
+     (Unit_Num : Unit_Number_Type;
+      Item     : Node_Id;
+      Prefix   : String := "";
+      Withs    : Boolean := False)
+   is
+   begin
+      Write_Str (Prefix);
+      Write_Unit_Name (Unit_Name (Unit_Num));
+      Write_Str (", unit ");
+      Write_Int (Int (Unit_Num));
+      Write_Str (", ");
+      Write_Int (Int (Item));
+      Write_Str ("=");
+      Write_Str (Node_Kind'Image (Nkind (Item)));
+
+      if Item /= Original_Node (Item) then
+         Write_Str (", orig = ");
+         Write_Int (Int (Original_Node (Item)));
+         Write_Str ("=");
+         Write_Str (Node_Kind'Image (Nkind (Original_Node (Item))));
+      end if;
+
+      Write_Eol;
+
+      --  Skip the rest if we're not supposed to print the withs
+
+      if not Withs then
+         return;
+      end if;
+
+      declare
+         Context_Item : Node_Id;
+
+      begin
+         Context_Item := First (Context_Items (Cunit (Unit_Num)));
+         while Present (Context_Item)
+           and then (Nkind (Context_Item) /= N_With_Clause
+                      or else Limited_Present (Context_Item))
+         loop
+            Context_Item := Next (Context_Item);
+         end loop;
+
+         if Present (Context_Item) then
+            Indent;
+            Write_Line ("withs:");
+            Indent;
+
+            while Present (Context_Item) loop
+               if Nkind (Context_Item) = N_With_Clause
+                 and then not Limited_Present (Context_Item)
+               then
+                  pragma Assert (Present (Library_Unit (Context_Item)));
+                  Write_Unit_Name
+                    (Unit_Name
+                       (Get_Cunit_Unit_Number (Library_Unit (Context_Item))));
+
+                  if Implicit_With (Context_Item) then
+                     Write_Str (" -- implicit");
+                  end if;
+
+                  Write_Eol;
+               end if;
+
+               Context_Item := Next (Context_Item);
+            end loop;
+
+            Outdent;
+            Write_Line ("end withs");
+            Outdent;
+         end if;
+      end;
+   end Write_Unit_Info;
+
 end Lib;
index 2b3f90650cd21d0931493aa4485abda28c9ea09a..d7607ee097ba9aae871525438f644aa9ea050e09 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-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- --
@@ -673,6 +673,15 @@ package Lib is
    --  that file not being compiled. The predicate Generic_May_Lack_ALI is
    --  True for those generic units for which missing ALI files are allowed.
 
+   procedure Write_Unit_Info
+     (Unit_Num : Unit_Number_Type;
+      Item     : Node_Id;
+      Prefix   : String := "";
+      Withs    : Boolean := False);
+   --  Print out debugging information about the unit. Prefix precedes the rest
+   --  of the printout. If Withs is True, we print out units with'ed by this
+   --  unit (not counting limited withs).
+
 private
    pragma Inline (Cunit);
    pragma Inline (Cunit_Entity);
index 5a1f469e078bd89fa49bbbf5eb86b4845bf28b74..e0834764865d9f9d8f3808544702b00ea8816c7c 100644 (file)
@@ -1183,6 +1183,7 @@ begin
            Pragma_Linker_Destructor              |
            Pragma_Linker_Options                 |
            Pragma_Linker_Section                 |
+           Pragma_Lock_Free                      |
            Pragma_Locking_Policy                 |
            Pragma_Long_Float                     |
            Pragma_Machine_Attribute              |
index 96bcc3c3bbcd602964e556a5b200ebe80ee0af7d..61cb2940c68b3a25d66a8ce8ce717d332d23e0d1 100644 (file)
@@ -46,27 +46,30 @@ package body System.Task_Primitives.Operations is
    pragma Warnings (Off);
    --  Turn off warnings since so many unreferenced parameters
 
-   --------------------
-   -- Local Packages --
-   --------------------
+   --------------
+   -- Specific --
+   --------------
 
-   package Specific is
+   --  Package Specific contains target specific routines, and the body of
+   --  this package is target specific.
 
+   package Specific is
       procedure Set (Self_Id : Task_Id);
       pragma Inline (Set);
       --  Set the self id for the current task
-
    end Specific;
 
    package body Specific is
 
+      ---------
+      -- Set --
+      ---------
+
       procedure Set (Self_Id : Task_Id) is
       begin
          null;
       end Set;
-
    end Specific;
-   --  The body of this package is target specific
 
    ----------------------------------
    -- ATCB allocation/deallocation --
index 503d1f40d4349dfe2a39c42339b780e4f7800457..352665af23fa1d83176a50f30eba2d6e7e7f0684 100644 (file)
@@ -91,15 +91,6 @@ package body Sem is
    --  of this unit, since they count as dependences on their parent library
    --  item. CU must be an N_Compilation_Unit whose Unit is not an N_Subunit.
 
-   procedure Write_Unit_Info
-     (Unit_Num : Unit_Number_Type;
-      Item     : Node_Id;
-      Prefix   : String := "";
-      Withs    : Boolean := False);
-   --  Print out debugging information about the unit. Prefix precedes the rest
-   --  of the printout. If Withs is True, we print out units with'ed by this
-   --  unit (not counting limited withs).
-
    -------------
    -- Analyze --
    -------------
@@ -2290,82 +2281,4 @@ package body Sem is
       end loop;
    end Walk_Withs_Immediate;
 
-   ---------------------
-   -- Write_Unit_Info --
-   ---------------------
-
-   procedure Write_Unit_Info
-     (Unit_Num : Unit_Number_Type;
-      Item     : Node_Id;
-      Prefix   : String := "";
-      Withs    : Boolean := False)
-   is
-   begin
-      Write_Str (Prefix);
-      Write_Unit_Name (Unit_Name (Unit_Num));
-      Write_Str (", unit ");
-      Write_Int (Int (Unit_Num));
-      Write_Str (", ");
-      Write_Int (Int (Item));
-      Write_Str ("=");
-      Write_Str (Node_Kind'Image (Nkind (Item)));
-
-      if Item /= Original_Node (Item) then
-         Write_Str (", orig = ");
-         Write_Int (Int (Original_Node (Item)));
-         Write_Str ("=");
-         Write_Str (Node_Kind'Image (Nkind (Original_Node (Item))));
-      end if;
-
-      Write_Eol;
-
-      --  Skip the rest if we're not supposed to print the withs
-
-      if not Withs then
-         return;
-      end if;
-
-      declare
-         Context_Item : Node_Id;
-
-      begin
-         Context_Item := First (Context_Items (Cunit (Unit_Num)));
-         while Present (Context_Item)
-           and then (Nkind (Context_Item) /= N_With_Clause
-                      or else Limited_Present (Context_Item))
-         loop
-            Context_Item := Next (Context_Item);
-         end loop;
-
-         if Present (Context_Item) then
-            Indent;
-            Write_Line ("withs:");
-            Indent;
-
-            while Present (Context_Item) loop
-               if Nkind (Context_Item) = N_With_Clause
-                 and then not Limited_Present (Context_Item)
-               then
-                  pragma Assert (Present (Library_Unit (Context_Item)));
-                  Write_Unit_Name
-                    (Unit_Name
-                       (Get_Cunit_Unit_Number (Library_Unit (Context_Item))));
-
-                  if Implicit_With (Context_Item) then
-                     Write_Str (" -- implicit");
-                  end if;
-
-                  Write_Eol;
-               end if;
-
-               Context_Item := Next (Context_Item);
-            end loop;
-
-            Outdent;
-            Write_Line ("end withs");
-            Outdent;
-         end if;
-      end;
-   end Write_Unit_Info;
-
 end Sem;
index bf700803086f3b718a8ad0c2559c85cf9bc897f4..1e95a6d76ef1c8d732fafe8b82aff2213558a23b 100644 (file)
@@ -3569,6 +3569,19 @@ package body Sem_Attr is
          Check_Array_Type;
          Set_Etype (N, Universal_Integer);
 
+      ---------------
+      -- Lock_Free --
+      ---------------
+
+      when Attribute_Lock_Free =>
+         Check_E0;
+         Set_Etype (N, Standard_Boolean);
+
+         if not Is_Protected_Type (P_Type) then
+            Error_Attr_P
+              ("prefix of % attribute must be a protected object");
+         end if;
+
       -------------
       -- Machine --
       -------------
@@ -6767,6 +6780,15 @@ package body Sem_Attr is
               True);
          end if;
 
+      ---------------
+      -- Lock_Free --
+      ---------------
+
+      --  Lock_Free attribute is a Boolean, thus no need to fold here.
+
+      when Attribute_Lock_Free =>
+         null;
+
       ----------
       -- Last --
       ----------
index 85c70f9137443cea1d30eba7727a4aabc63b86b4..bf09e99ba5a2b6c17302fbf632b7b62d18b5a9aa 100644 (file)
@@ -163,7 +163,7 @@ package Sem_Aux is
    --  Searches the Rep_Item chain for a given entity E, for an instance of a
    --  rep item (pragma, attribute definition clause, or aspect specification)
    --  whose name matches the given name Nam. If Check_Parents is False then it
-   --  only returns rep item that has been directly specified to E (and not
+   --  only returns rep item that has been directly specified for E (and not
    --  inherited from its parents, if any). If one is found, it is returned,
    --  otherwise Empty is returned. A special case is that when Nam is
    --  Name_Priority, the call will also find Interrupt_Priority.
@@ -172,11 +172,11 @@ package Sem_Aux is
      (E             : Entity_Id;
       Nam           : Name_Id;
       Check_Parents : Boolean := True) return Node_Id;
-   --  Searches the Rep_Item chain for a given entity E, for an instance of a
-   --  representation pragma whose name matches the given name Nam. If
+   --  Searches the Rep_Item chain for a given entity E, for an instance
+   --  of a representation pragma whose name matches the given name Nam. If
    --  Check_Parents is False then it only returns representation pragma that
-   --  has been directly specified to E (and not inherited from its parents, if
-   --  any). If one is found, it is returned, otherwise Empty is returned. A
+   --  has been directly specified for E (and not inherited from its parents,
+   --  if any). If one is found, it is returned, otherwise Empty is returned. A
    --  special case is that when Nam is Name_Priority, the call will also find
    --  Interrupt_Priority.
 
@@ -186,10 +186,10 @@ package Sem_Aux is
       Check_Parents : Boolean := True) return Boolean;
    --  Searches the Rep_Item chain for the given entity E, for an instance of a
    --  rep item (pragma, attribute definition clause, or aspect specification)
-   --  with the given name Nam. If Check_Parents is False then it only returns
-   --  rep item that has been directly specified to E (and not inherited from
-   --  its parents, if any). If found then True is returned, otherwise False
-   --  indicates that no matching entry was found.
+   --  with the given name Nam. If Check_Parents is False then it only checks
+   --  for a rep item that has been directly specified for E (and not inherited
+   --  from its parents, if any). If found then True is returned, otherwise
+   --  False indicates that no matching entry was found.
 
    function Has_Rep_Pragma
      (E             : Entity_Id;
@@ -197,8 +197,8 @@ package Sem_Aux is
       Check_Parents : Boolean := True) return Boolean;
    --  Searches the Rep_Item chain for the given entity E, for an instance of a
    --  representation pragma with the given name Nam. If Check_Parents is False
-   --  then it only returns representation pragma that has been directly
-   --  specified to E (and not inherited from its parents, if any). If found
+   --  then it only checks for a representation pragma that has been directly
+   --  specified for E (and not inherited from its parents, if any). If found
    --  then True is returned, otherwise False indicates that no matching entry
    --  was found.
 
index 82fde3f7191fb2e5be59b6fd6c50738791935a22..6ed11b877665bb35bd92d93e5c0f288dbc0fe72b 100644 (file)
@@ -1261,7 +1261,6 @@ package body Sem_Ch10 is
         and then Warn_On_Obsolescent_Feature
         and then Nkind (Unit_Node) not in N_Generic_Instantiation
       then
-
          --  Push current compilation unit as scope, so that the test for
          --  being within an obsolescent unit will work correctly. The check
          --  is not performed within an instantiation, because the warning
index 63b29c10c7dc08d9b98183fd9e4ed2a6431b85d6..ddfa7e75b0c8ee2bd737c50598e0dc70638c5bde 100644 (file)
@@ -1445,6 +1445,8 @@ package body Sem_Ch13 is
                         then
                            Set_Uses_Lock_Free (E);
                         end if;
+
+                        Record_Rep_Item (E, Aspect);
                      end if;
 
                      goto Continue;
index c69bf918e5d24ed00b0e96b358622eb965136857..d0f918df3977aead55ebf0f1ed2cb60041fd287c 100644 (file)
@@ -5503,6 +5503,18 @@ package body Sem_Ch6 is
             end if;
          end if;
 
+         --  Ada 2012:  mode conformance also requires that formal parameters
+         --  be both aliased, or neither.
+
+         if Ctype >= Mode_Conformant
+           and then Ada_Version >= Ada_2012
+         then
+            if Is_Aliased (Old_Formal) /= Is_Aliased (New_Formal) then
+               Conformance_Error
+                 ("\aliased parameter mismatch!", New_Formal);
+            end if;
+         end if;
+
          if Ctype = Fully_Conformant then
 
             --  Names must match. Error message is more accurate if we do
index ced4d51640d8ffb2816799375742407400658adb..58a27c9325658b5d44d32ac7a4301510e186a25e 100644 (file)
@@ -23,7 +23,6 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Aspects;  use Aspects;
 with Atree;    use Atree;
 with Checks;   use Checks;
 with Debug;    use Debug;
@@ -263,16 +262,41 @@ package body Sem_Ch9 is
                begin
                   --  Function calls and attribute references must be static
 
-                  if Nkind_In (N, N_Attribute_Reference, N_Function_Call)
+                  if Nkind (N) = N_Attribute_Reference
                     and then not Is_Static_Expression (N)
                   then
+                     if Complain then
+                        Error_Msg_N
+                          ("non-static attribute reference not allowed",
+                           N);
+                     end if;
+
+                     return Abandon;
+
+                  elsif Nkind (N) = N_Function_Call
+                    and then not Is_Static_Expression (N)
+                  then
+                     if Complain then
+                        Error_Msg_N ("non-static function call not allowed",
+                                     N);
+                     end if;
+
                      return Abandon;
 
                   --  Loop statements and procedure calls are prohibited
 
-                  elsif Nkind_In (N, N_Loop_Statement,
-                                     N_Procedure_Call_Statement)
-                  then
+                  elsif Nkind (N) = N_Loop_Statement then
+                     if Complain then
+                        Error_Msg_N ("loop not allowed", N);
+                     end if;
+
+                     return Abandon;
+
+                  elsif Nkind (N) = N_Procedure_Call_Statement then
+                     if Complain then
+                        Error_Msg_N ("procedure call not allowed", N);
+                     end if;
+
                      return Abandon;
 
                   --  References
@@ -295,6 +319,12 @@ package body Sem_Ch9 is
                           and then not Scope_Within_Or_Same (Scope (Id),
                                          Protected_Body_Subprogram (Sub_Id))
                         then
+                           if Complain then
+                              Error_Msg_NE
+                                ("reference to global variable& not allowed",
+                                 N, Id);
+                           end if;
+
                            return Abandon;
 
                         --  Prohibit non-scalar out parameters (scalar
@@ -305,6 +335,12 @@ package body Sem_Ch9 is
                           and then not Is_Elementary_Type (Etype (Id))
                           and then Scope_Within_Or_Same (Scope (Id), Sub_Id)
                         then
+                           if Complain then
+                              Error_Msg_NE
+                                ("non-elementary out parameter& not allowed",
+                                 N, Id);
+                           end if;
+
                            return Abandon;
 
                         --  A protected subprogram may reference only one
@@ -327,6 +363,13 @@ package body Sem_Ch9 is
                                  --  body.
 
                                  elsif Comp /= Id then
+                                    if Complain then
+                                       Error_Msg_N
+                                         ("only one protected component " &
+                                          "allowed",
+                                          N);
+                                    end if;
+
                                     return Abandon;
                                  end if;
                               end if;
@@ -352,6 +395,13 @@ package body Sem_Ch9 is
                                  --  body.
 
                                  elsif Comp /= Prival_Link (Id) then
+                                    if Complain then
+                                       Error_Msg_N
+                                         ("only one protected component " &
+                                          "allowed",
+                                          N);
+                                    end if;
+
                                     return Abandon;
                                  end if;
                               end if;
@@ -1375,7 +1425,6 @@ package body Sem_Ch9 is
 
    procedure Analyze_Protected_Body (N : Node_Id) is
       Body_Id : constant Entity_Id := Defining_Identifier (N);
-      Aspect  : Node_Id;
       Last_E  : Entity_Id;
 
       Spec_Id : Entity_Id;
@@ -1390,6 +1439,50 @@ package body Sem_Ch9 is
       --  differs from Spec_Id in the case of a single protected object, since
       --  Spec_Id is set to the protected type in this case).
 
+      function Lock_Free_Disabled return Boolean;
+      --  This routine returns False if the protected object has a Lock_Free
+      --  aspect specification or a Lock_Free pragma that turns off the
+      --  lock-free implementation (e.g. whose expression is False).
+
+      ------------------------
+      -- Lock_Free_Disabled --
+      ------------------------
+
+      function Lock_Free_Disabled return Boolean is
+         Ritem : constant Node_Id :=
+                   Get_Rep_Item
+                     (Spec_Id, Name_Lock_Free, Check_Parents => False);
+
+      begin
+         if Present (Ritem) then
+            --  Pragma with one argument
+
+            if Nkind (Ritem) = N_Pragma
+              and then Present (Pragma_Argument_Associations (Ritem))
+            then
+               return
+                 Is_False (Static_Boolean
+                  (Expression (First (Pragma_Argument_Associations (Ritem)))));
+
+            --  Aspect Specification with expression present
+
+            elsif Nkind (Ritem) = N_Aspect_Specification
+              and then Present (Expression (Ritem))
+            then
+               return Is_False (Static_Boolean (Expression (Ritem)));
+
+            --  Otherwise, return False
+
+            else
+               return False;
+            end if;
+         end if;
+
+         return False;
+      end Lock_Free_Disabled;
+
+   --  Start of processing for Analyze_Protected_Body
+
    begin
       Tasking_Used := True;
       Set_Ekind (Body_Id, E_Protected_Body);
@@ -1450,37 +1543,21 @@ package body Sem_Ch9 is
       Process_End_Label (N, 't', Ref_Id);
       End_Scope;
 
-      --  Turn on/off the lock-free implementation for the protected object
-
-      --  Look for a Lock_Free aspect with a False expression that disables the
-      --  lock-free implementation.
-
-      Aspect := First (Aspect_Specifications (Parent (Spec_Id)));
-
-      while Present (Aspect) loop
-         if Get_Aspect_Id (Chars (Identifier (Aspect))) = Aspect_Lock_Free
-           and then Present (Expression (Aspect))
-           and then Entity (Expression (Aspect)) = Standard_False
-         then
-            return;
-         end if;
-
-         Next (Aspect);
-      end loop;
-
-      --  When a Lock_Free aspect forces the lock-free implementation, verify
-      --  the protected body meets all the restrictions, otherwise
-      --  Allows_Lock_Free_Implementation issues an error message.
+      --  When a Lock_Free aspect specification/pragma forces the lock-free
+      --  implementation, verify the protected body meets all the restrictions,
+      --  otherwise Allows_Lock_Free_Implementation issues an error message.
 
       if Uses_Lock_Free (Spec_Id) then
          if not Allows_Lock_Free_Implementation (N, Complain => True) then
             return;
          end if;
 
-      --  In other cases, check both the protected declaration and body satisfy
-      --  the lock-free restrictions.
+      --  In other cases, if there is no aspect specification/pragma that
+      --  disables the lock-free implementation, check both the protected
+      --  declaration and body satisfy the lock-free restrictions.
 
-      elsif Allows_Lock_Free_Implementation (Parent (Spec_Id))
+      elsif not Lock_Free_Disabled
+        and then Allows_Lock_Free_Implementation (Parent (Spec_Id))
         and then Allows_Lock_Free_Implementation (N)
       then
          Set_Uses_Lock_Free (Spec_Id);
index 35e1f6404eed851f6a23cc2c8da4d2239f894bc3..8b2eb1c908cfe52bf181a6c6be0ef3caa3d8bbdc 100644 (file)
@@ -11118,6 +11118,54 @@ package body Sem_Prag is
          when Pragma_List =>
             null;
 
+         ---------------
+         -- Lock_Free --
+         ---------------
+
+         --  pragma Lock_Free [(Boolean_EXPRESSION)];
+
+         when Pragma_Lock_Free => Lock_Free : declare
+            P   : constant Node_Id := Parent (N);
+            Arg : Node_Id;
+            Ent : Entity_Id;
+            Val : Boolean;
+
+         begin
+            Check_No_Identifiers;
+            Check_At_Most_N_Arguments (1);
+
+            --  Protected definition case
+
+            if Nkind (P) = N_Protected_Definition then
+               Ent := Defining_Identifier (Parent (P));
+
+               --  One argument
+
+               if Arg_Count = 1 then
+                  Arg := Get_Pragma_Arg (Arg1);
+                  Val := Is_True (Static_Boolean (Arg));
+
+               --  Zero argument. In this case the expression is considered to
+               --  be True.
+
+               else
+                  Val := True;
+               end if;
+
+               --  Check duplicate pragma before we chain the pragma in the Rep
+               --  Item chain of Ent.
+
+               Check_Duplicate_Pragma (Ent);
+               Record_Rep_Item        (Ent, N);
+               Set_Uses_Lock_Free     (Ent, Val);
+
+            --  Anything else is incorrect
+
+            else
+               Pragma_Misplaced;
+            end if;
+         end Lock_Free;
+
          --------------------
          -- Locking_Policy --
          --------------------
@@ -15212,6 +15260,7 @@ package body Sem_Prag is
       Pragma_Linker_Options                 => -1,
       Pragma_Linker_Section                 => -1,
       Pragma_List                           => -1,
+      Pragma_Lock_Free                      => -1,
       Pragma_Locking_Policy                 => -1,
       Pragma_Long_Float                     => -1,
       Pragma_Machine_Attribute              => -1,
index 017be8368dcdcf8268e4fd4e7823793974c877a5..f42c75478163949f4f9e05acd82da13436deb984 100644 (file)
@@ -7745,14 +7745,13 @@ package body Sem_Util is
             when N_String_Literal =>
                return Is_Internally_Generated_Renaming (Parent (N));
 
-            --  AI05-0003:  in Ada 2012, a qualified expression is a name.
-            --  This allows disambiguation of function calls and the use of
-            --  aggregates in more contexts.
+            --  AI05-0003: In Ada 2012 a qualified expression is a name.
+            --  This allows disambiguation of function calls and the use
+            --  of aggregates in more contexts.
 
             when N_Qualified_Expression =>
                if Ada_Version <  Ada_2012 then
                   return False;
-
                else
                   return Is_Object_Reference (Expression (N))
                     or else Nkind (Expression (N)) = N_Aggregate;
index 0beb51fd1e9d506ddcd81735e2a293df449f0442..4ac3c220549ce019220d64d1154324b5c48f7c3a 100644 (file)
@@ -219,6 +219,8 @@ package body Snames is
          return Pragma_Interface;
       elsif N = Name_Interrupt_Priority then
          return Pragma_Interrupt_Priority;
+      elsif N = Name_Lock_Free then
+         return Pragma_Lock_Free;
       elsif N = Name_Priority then
          return Pragma_Priority;
       elsif N = Name_Relative_Deadline then
@@ -421,6 +423,7 @@ package body Snames is
         or else N = Name_Fast_Math
         or else N = Name_Interface
         or else N = Name_Interrupt_Priority
+        or else N = Name_Lock_Free
         or else N = Name_Relative_Deadline
         or else N = Name_Priority
         or else N = Name_Storage_Size
index 4b1b337d036a46117e692a1a0a77c1b2a3b9b43b..38bab59120bb8be0b9895ad7478ab357804cc1f2 100644 (file)
@@ -142,7 +142,6 @@ package Snames is
    Name_Dimension                      : constant Name_Id := N + $;
    Name_Dimension_System               : constant Name_Id := N + $;
    Name_Dynamic_Predicate              : constant Name_Id := N + $;
-   Name_Lock_Free                      : constant Name_Id := N + $;
    Name_Post                           : constant Name_Id := N + $;
    Name_Pre                            : constant Name_Id := N + $;
    Name_Static_Predicate               : constant Name_Id := N + $;
@@ -522,6 +521,12 @@ package Snames is
    Name_Linker_Options                 : constant Name_Id := N + $;
    Name_Linker_Section                 : constant Name_Id := N + $; -- GNAT
    Name_List                           : constant Name_Id := N + $;
+
+   --  Note: Lock_Free is not in this list because its name matches the name of
+   --  the corresponding attribute. However, it is included in the definition
+   --  of the type Pragma_Id, and the functions Get_Pragma_Id and Is_Pragma_Id
+   --  correctly recognize and process Lock_Free. Lock_Free is a GNAT pragma.
+
    Name_Machine_Attribute              : constant Name_Id := N + $; -- GNAT
    Name_Main                           : constant Name_Id := N + $; -- GNAT
    Name_Main_Storage                   : constant Name_Id := N + $; -- GNAT
@@ -810,6 +815,7 @@ package Snames is
    Name_Last_Valid                     : constant Name_Id := N + $; -- Ada 12
    Name_Leading_Part                   : constant Name_Id := N + $;
    Name_Length                         : constant Name_Id := N + $;
+   Name_Lock_Free                      : constant Name_Id := N + $; -- GNAT
    Name_Machine_Emax                   : constant Name_Id := N + $;
    Name_Machine_Emin                   : constant Name_Id := N + $;
    Name_Machine_Mantissa               : constant Name_Id := N + $;
@@ -1388,6 +1394,7 @@ package Snames is
       Attribute_Last_Valid,
       Attribute_Leading_Part,
       Attribute_Length,
+      Attribute_Lock_Free,
       Attribute_Machine_Emax,
       Attribute_Machine_Emin,
       Attribute_Machine_Mantissa,
@@ -1774,6 +1781,7 @@ package Snames is
       Pragma_Fast_Math,
       Pragma_Interface,
       Pragma_Interrupt_Priority,
+      Pragma_Lock_Free,
       Pragma_Priority,
       Pragma_Storage_Size,
       Pragma_Storage_Unit,
@@ -1853,8 +1861,8 @@ package Snames is
    function Is_Pragma_Name (N : Name_Id) return Boolean;
    --  Test to see if the name N is the name of a recognized pragma. Note that
    --  pragmas AST_Entry, CPU, Dispatching_Domain, Fast_Math,
-   --  Interrupt_Priority, Priority, Storage_Size, and Storage_Unit are
-   --  recognized as pragmas by this function even though their names are
+   --  Interrupt_Priority, Lock_Free, Priority, Storage_Size, and Storage_Unit
+   --  are recognized as pragmas by this function even though their names are
    --  separate from the other pragma names. For this reason, clients should
    --  always use this function, rather than do range tests on Name_Id values.
 
@@ -1895,8 +1903,9 @@ package Snames is
    --  if N is not a name of a known (Ada defined or GNAT-specific) pragma.
    --  Note that the function also works correctly for names of pragmas that
    --  are not included in the main list of pragma Names (AST_Entry, CPU,
-   --  Dispatching_Domain, Interrupt_Priority, Priority, Storage_Size, and
-   --  Storage_Unit (e.g. Name_Storage_Size returns Pragma_Storage_Size).
+   --  Dispatching_Domain, Interrupt_Priority, Lock_Free, Priority,
+   --  Storage_Size, and Storage_Unit (e.g. Name_Storage_Size returns
+   --  Pragma_Storage_Size).
 
    function Get_Queuing_Policy_Id (N : Name_Id) return Queuing_Policy_Id;
    --  Returns Id of queuing policy corresponding to given name. It is an error