[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Tue, 12 Jun 2012 09:01:03 +0000 (11:01 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Tue, 12 Jun 2012 09:01:03 +0000 (11:01 +0200)
2012-06-12  Eric Botcazou  <ebotcazou@adacore.com>

* sem_util.adb (Is_Atomic_Object): Return true for an atomic
component as well as a prefix which is an atomic component.

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

* exp_prag.adb (Expand_Pragma_Import_Or_Interface): revert previous
patch. The processing of interfacing aspects now generates a
proper Ada 2005 pragma.
* sem_prag.adb (Analyze_Pragma, cases Pragma_Export and
Pragma_Import): revert previous patch. The processing of
interfacing aspects now generates a proper Ada 2005 pragma.
* sem_ch13.adb (Analyze_Aspect_Specifications): generate proper
pragam for aspects Convention, Import and Export. Scan list
of aspects to collect link name and external name if present,
and verify that a complete pragma can be generated.

From-SVN: r188430

gcc/ada/ChangeLog
gcc/ada/exp_prag.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb

index 0b6ab7bf92c66f61c09aebba8acf6801887e3719..0d4a8deffce718f6fb0df031f3001851964a74e8 100644 (file)
@@ -1,3 +1,21 @@
+2012-06-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * sem_util.adb (Is_Atomic_Object): Return true for an atomic
+       component as well as a prefix which is an atomic component.
+
+2012-06-12  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_prag.adb (Expand_Pragma_Import_Or_Interface): revert previous
+       patch. The processing of interfacing aspects now generates a
+       proper Ada 2005 pragma.
+       * sem_prag.adb (Analyze_Pragma, cases Pragma_Export and
+       Pragma_Import): revert previous patch.  The processing of
+       interfacing aspects now generates a proper Ada 2005 pragma.
+       * sem_ch13.adb (Analyze_Aspect_Specifications): generate proper
+       pragam for aspects Convention, Import and Export. Scan list
+       of aspects to collect link name and external name if present,
+       and verify that a complete pragma can be generated.
+
 2012-06-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Convert GNU_SIZE
index d283a6e397ee764fdfe25feaa17e844344b9bef2..469cb8379fc8ad3c149954fa3301f1b2795929ee 100644 (file)
@@ -531,14 +531,7 @@ package body Exp_Prag is
       Init_Call : Node_Id;
 
    begin
-      --  If the pragma comes from an aspect, the entity is its first argument.
-
-      if Present (Corresponding_Aspect (N)) then
-         Def_Id := Entity (Arg1 (N));
-      else
-         Def_Id := Entity (Arg2 (N));
-      end if;
-
+      Def_Id := Entity (Arg2 (N));
       if Ekind (Def_Id) = E_Variable then
 
          --  Find generated initialization call for object, if any
index 984462a025fade309a0fa60cec91f0740d670e23..1d8e268dd6beb442b9dafd5265b92249154603fc 100644 (file)
@@ -948,6 +948,33 @@ package body Sem_Ch13 is
                         Set_Uses_Lock_Free (E);
                      end if;
 
+                     goto Continue;
+
+                  elsif A_Id = Aspect_Import
+                    or else A_Id = Aspect_Export
+                  then
+
+                     --  Verify that there is an aspect Convention that will
+                     --  incorporate the Import/Export aspect, and eventual
+                     --  Link/External names.
+
+                     declare
+                        A : Node_Id;
+
+                     begin
+                        A := First (L);
+                        while Present (A) loop
+                           exit when Chars (Identifier (A)) = Name_Convention;
+                           Next (A);
+                        end loop;
+
+                        if No (A) then
+                           Error_Msg_N
+                             ("missing Convention aspect for Export/Import",
+                                 Aspect);
+                        end if;
+                     end;
+
                      goto Continue;
                   end if;
 
@@ -1168,13 +1195,73 @@ package body Sem_Ch13 is
                --  the second argument is a local name referring to the entity,
                --  and the first argument is the aspect definition expression.
 
-               when Aspect_Convention =>
-                  Aitem :=
-                    Make_Pragma (Loc,
-                      Pragma_Argument_Associations =>
-                        New_List (Relocate_Node (Expr), Ent),
-                      Pragma_Identifier            =>
-                        Make_Identifier (Sloc (Id), Chars (Id)));
+               when Aspect_Convention  =>
+
+                  --  The aspect may be part of the specification of an import
+                  --  or export pragma. Scan the aspect list to gather the
+                  --  other components, if any. The name of the generated
+                  --  pragma is one of Convention/Import/Export.
+
+                  declare
+                     P_Name   : Name_Id;
+                     A_Name   : Name_Id;
+                     A        : Node_Id;
+                     Arg_List : List_Id;
+                     Found    : Boolean;
+                     L_Assoc  : Node_Id;
+                     E_Assoc  : Node_Id;
+
+                  begin
+                     P_Name   := Chars (Id);
+                     Found    := False;
+                     Arg_List := New_List;
+                     L_Assoc  := Empty;
+                     E_Assoc  := Empty;
+
+                     A := First (L);
+                     while Present (A) loop
+                        A_Name := Chars (Identifier (A));
+
+                        if A_Name = Name_Import
+                          or else A_Name = Name_Export
+                        then
+                           if Found then
+                              Error_Msg_N ("conflicting", A);
+                           else
+                              Found := True;
+                           end if;
+
+                           P_Name := A_Name;
+
+                        elsif A_Name = Name_Link_Name then
+                           L_Assoc := Make_Pragma_Argument_Association (Loc,
+                              Chars => A_Name,
+                              Expression => Relocate_Node (Expression (A)));
+
+                        elsif A_Name = Name_External_Name then
+                           E_Assoc := Make_Pragma_Argument_Association (Loc,
+                              Chars => A_Name,
+                              Expression => Relocate_Node (Expression (A)));
+                        end if;
+
+                        Next (A);
+                     end loop;
+
+                     Arg_List := New_List (Relocate_Node (Expr), Ent);
+                     if Present (L_Assoc) then
+                        Append_To (Arg_List, L_Assoc);
+                     end if;
+
+                     if Present (E_Assoc) then
+                        Append_To (Arg_List, E_Assoc);
+                     end if;
+
+                     Aitem :=
+                       Make_Pragma (Loc,
+                         Pragma_Argument_Associations => Arg_List,
+                         Pragma_Identifier            =>
+                            Make_Identifier (Loc, P_Name));
+                  end;
 
                when Aspect_Warnings =>
 
@@ -1570,13 +1657,33 @@ package body Sem_Ch13 is
                   Analyze_Aspect_Dimension_System (N, Id, Expr);
                   goto Continue;
 
-               --  Placeholders for new aspects without corresponding pragmas
+               when Aspect_External_Name |
+                    Aspect_Link_Name     =>
 
-               when Aspect_External_Name =>
-                  null;
+                  --  Verify that there is an Import/Export aspect defined for
+                  --  the entity. The processing of that aspect in turn checks
+                  --  that there is a Convention aspect declared. The pragma is
+                  --  constructed when processing the Convention aspect.
 
-               when Aspect_Link_Name =>
-                  null;
+                  declare
+                     A : Node_Id;
+
+                  begin
+                     A := First (L);
+                     while Present (A) loop
+                        exit when Chars (Identifier (A)) = Name_Export
+                          or else Chars (Identifier (A)) = Name_Import;
+                        Next (A);
+                     end loop;
+
+                     if No (A) then
+                        Error_Msg_N
+                          ("Missing Import/Export for Link/External name",
+                               Aspect);
+                     end if;
+                  end;
+
+                  goto Continue;
             end case;
 
             --  If a delay is required, we delay the freeze (not much point in
index 5279fb240974ed1c095c0dc9fa45e919df416a74..fa41b2c6f3f0841f49b39f71a51eef1488db3304 100644 (file)
@@ -8647,28 +8647,7 @@ package body Sem_Prag is
                 Name_External_Name,
                 Name_Link_Name));
 
-            if Present (Corresponding_Aspect (N)) then
-
-               --  If the pragma comes from an Aspect, there is a single entity
-               --  parameter and an optional booean value with default true.
-               --  The convention must be provided by a separate aspect.
-
-               Check_At_Least_N_Arguments (1);
-               Check_At_Most_N_Arguments  (2);
-               Def_Id := Entity (Arg1);
-
-               if No (Arg2) then
-
-                  --  If the aspect has a default True value, set corresponding
-                  --  flag on the entity.
-
-                  Set_Is_Exported (Def_Id);
-               end if;
-               return;
-
-            else
-               Check_At_Least_N_Arguments (2);
-            end if;
+            Check_At_Least_N_Arguments (2);
 
             Check_At_Most_N_Arguments  (4);
             Process_Convention (C, Def_Id);
@@ -9603,29 +9582,9 @@ package body Sem_Prag is
                 Name_External_Name,
                 Name_Link_Name));
 
-            if Present (Corresponding_Aspect (N)) then
-
-               --  If the pragma comes from an Aspect, there is a single entity
-               --  parameter and an optional booean value with default true.
-               --  The convention must be provided by a separate aspect.
-
-               Check_At_Least_N_Arguments (1);
-               Check_At_Most_N_Arguments  (2);
-
-               if No (Arg2) then
-
-                  --  If the aspect has a default True value, set corresponding
-                  --  flag on the entity.
-
-                  Set_Is_Imported (Entity (Arg1));
-               end if;
-               return;
-
-            else
-               Check_At_Least_N_Arguments (2);
-               Check_At_Most_N_Arguments  (4);
-               Process_Import_Or_Interface;
-            end if;
+            Check_At_Least_N_Arguments (2);
+            Check_At_Most_N_Arguments  (4);
+            Process_Import_Or_Interface;
 
          ----------------------
          -- Import_Exception --
index 1ca02d1133279314ec29c27794800e5535c3ac14..a5c60b51f1940b3b76adca23fe129936a982a75a 100644 (file)
@@ -6749,6 +6749,11 @@ package body Sem_Util is
          then
             return True;
 
+         elsif Nkind (N) = N_Selected_Component
+           and then Is_Atomic (Entity (Selector_Name (N)))
+         then
+            return True;
+
          elsif Nkind (N) = N_Indexed_Component
            or else Nkind (N) = N_Selected_Component
          then
@@ -6772,6 +6777,11 @@ package body Sem_Util is
       then
          return True;
 
+      elsif Nkind (N) = N_Selected_Component
+        and then Is_Atomic (Entity (Selector_Name (N)))
+      then
+         return True;
+
       elsif Nkind (N) = N_Indexed_Component
         or else Nkind (N) = N_Selected_Component
       then