From: Arnaud Charlet Date: Tue, 12 Jun 2012 09:01:03 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9d6e41574cd7a8c928f57f89498bc9b4e77681fa;p=gcc.git [multiple changes] 2012-06-12 Eric Botcazou * 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 * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0b6ab7bf92c..0d4a8deffce 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,21 @@ +2012-06-12 Eric Botcazou + + * 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 + + * 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 * gcc-interface/decl.c (gnat_to_gnu_entity) : Convert GNU_SIZE diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb index d283a6e397e..469cb8379fc 100644 --- a/gcc/ada/exp_prag.adb +++ b/gcc/ada/exp_prag.adb @@ -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 diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 984462a025f..1d8e268dd6b 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -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 diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 5279fb24097..fa41b2c6f3f 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -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 -- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 1ca02d11332..a5c60b51f19 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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