diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-04 13:51:43 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-04 13:51:43 +0000 |
commit | 0c888ad177ad08a2bac14e762ddced0beed5647c (patch) | |
tree | 828bbf6fbd489f2ef494e6151a1c4d1d49ecf151 /gcc/ada/sem_prag.adb | |
parent | 8b407655ed1a6e1300b60482f455c32e8b662a8b (diff) | |
download | gcc-0c888ad177ad08a2bac14e762ddced0beed5647c.tar.gz |
2008-08-04 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r138620
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@138622 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_prag.adb')
-rw-r--r-- | gcc/ada/sem_prag.adb | 350 |
1 files changed, 233 insertions, 117 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 8d162e6b37b..3ad8ff5d21b 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -53,6 +53,7 @@ with Sem_Aux; use Sem_Aux; with Sem_Ch3; use Sem_Ch3; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; +with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dist; use Sem_Dist; with Sem_Elim; use Sem_Elim; @@ -1424,7 +1425,18 @@ package body Sem_Prag is P := N; while Present (Prev (P)) loop P := Prev (P); - PO := Original_Node (P); + + -- If the previous node is a generic subprogram, do not go to + -- to the original node, which is the unanalyzed tree: we need + -- to attach the pre/postconditions to the analyzed version + -- at this point. They get propagated to the original tree when + -- analyzing the corresponding body. + + if Nkind (P) not in N_Generic_Declaration then + PO := Original_Node (P); + else + PO := P; + end if; -- Skip past prior pragma @@ -1450,6 +1462,15 @@ package body Sem_Prag is if Nkind (Parent (N)) = N_Subprogram_Body and then List_Containing (N) = Declarations (Parent (N)) then + if Operating_Mode /= Generate_Code then + + -- Analyze expression in pragma, for correctness + -- and for ASIS use. + + Preanalyze_Spec_Expression + (Get_Pragma_Arg (Arg1), Standard_Boolean); + end if; + In_Body := True; return; @@ -2221,7 +2242,6 @@ package body Sem_Prag is Arg1x : constant Node_Id := Get_Pragma_Arg (Arg1); begin - GNAT_Pragma; Check_Arg_Count (2); Check_No_Identifiers; Check_Arg_Is_Static_Expression (Arg2, Standard_String); @@ -2638,8 +2658,6 @@ package body Sem_Prag is Code_Val : Uint; begin - GNAT_Pragma; - if not OpenVMS_On_Target then Error_Pragma ("?pragma% ignored (applies only to Open'V'M'S)"); @@ -2697,8 +2715,6 @@ package body Sem_Prag is (Arg_Internal : Node_Id := Empty) is begin - GNAT_Pragma; - if No (Arg_Internal) then Error_Pragma ("Internal parameter required for pragma%"); end if; @@ -3315,7 +3331,6 @@ package body Sem_Prag is Exp : Node_Id; begin - GNAT_Pragma; Check_No_Identifiers; Check_At_Least_N_Arguments (1); @@ -3752,6 +3767,22 @@ package body Sem_Prag is and then Present (Corresponding_Body (Decl)) then Set_Inline_Flags (Corresponding_Body (Decl)); + + elsif Is_Generic_Instance (Subp) then + + -- Indicate that the body needs to be created for + -- inlining subsequent calls. The instantiation + -- node follows the declaration of the wrapper + -- package created for it. + + if Scope (Subp) /= Standard_Standard + and then + Need_Subprogram_Instance_Body + (Next (Unit_Declaration_Node (Scope (Alias (Subp)))), + Subp) + then + null; + end if; end if; end if; @@ -3870,17 +3901,23 @@ package body Sem_Prag is Link_Nam : Node_Id; String_Val : String_Id; - procedure Check_Form_Of_Interface_Name (SN : Node_Id); + procedure Check_Form_Of_Interface_Name + (SN : Node_Id; + Ext_Name_Case : Boolean); -- SN is a string literal node for an interface name. This routine -- performs some minimal checks that the name is reasonable. In -- particular that no spaces or other obviously incorrect characters -- appear. This is only a warning, since any characters are allowed. + -- Ext_Name_Case is True for an External_Name, False for a Link_Name. ---------------------------------- -- Check_Form_Of_Interface_Name -- ---------------------------------- - procedure Check_Form_Of_Interface_Name (SN : Node_Id) is + procedure Check_Form_Of_Interface_Name + (SN : Node_Id; + Ext_Name_Case : Boolean) + is S : constant String_Id := Strval (Expr_Value_S (SN)); SL : constant Nat := String_Length (S); C : Char_Code; @@ -3893,15 +3930,28 @@ package body Sem_Prag is for J in 1 .. SL loop C := Get_String_Char (S, J); - if Warn_On_Export_Import - and then - (not In_Character_Range (C) - or else (Get_Character (C) = ' ' - and then VM_Target /= CLI_Target) - or else Get_Character (C) = ',') + -- Look for dubious character and issue unconditional warning. + -- Definitely dubious if not in character range. + + if not In_Character_Range (C) + + -- For all cases except external names on CLI target, + -- commas, spaces and slashes are dubious (in CLI, we use + -- spaces and commas in external names to specify assembly + -- version and public key). + + or else ((not Ext_Name_Case or else VM_Target /= CLI_Target) + and then (Get_Character (C) = ' ' + or else + Get_Character (C) = ',' + or else + Get_Character (C) = '/' + or else + Get_Character (C) = '\')) then - Error_Msg_N - ("?interface name contains illegal character", SN); + Error_Msg + ("?interface name contains illegal character", + Sloc (SN) + Source_Ptr (J)); end if; end loop; end Check_Form_Of_Interface_Name; @@ -3946,13 +3996,13 @@ package body Sem_Prag is if Present (Ext_Nam) then Check_Arg_Is_Static_Expression (Ext_Nam, Standard_String); - Check_Form_Of_Interface_Name (Ext_Nam); + Check_Form_Of_Interface_Name (Ext_Nam, Ext_Name_Case => True); - -- Verify that the external name is not the name of a local - -- entity, which would hide the imported one and lead to - -- run-time surprises. The problem can only arise for entities - -- declared in a package body (otherwise the external name is - -- fully qualified and won't conflict). + -- Verify that external name is not the name of a local entity, + -- which would hide the imported one and could lead to run-time + -- surprises. The problem can only arise for entities declared in + -- a package body (otherwise the external name is fully qualified + -- and will not conflict). declare Nam : Name_Id; @@ -3975,10 +4025,10 @@ package body Sem_Prag is Par := Parent (E); while Present (Par) loop if Nkind (Par) = N_Package_Body then - Error_Msg_Sloc := Sloc (E); + Error_Msg_Sloc := Sloc (E); Error_Msg_NE ("imported entity is hidden by & declared#", - Ext_Arg, E); + Ext_Arg, E); exit; end if; @@ -3991,7 +4041,7 @@ package body Sem_Prag is if Present (Link_Nam) then Check_Arg_Is_Static_Expression (Link_Nam, Standard_String); - Check_Form_Of_Interface_Name (Link_Nam); + Check_Form_Of_Interface_Name (Link_Nam, Ext_Name_Case => False); end if; -- If there is no link name, just set the external name @@ -4622,6 +4672,7 @@ package body Sem_Prag is procedure Set_Mechanism_Value (Ent : Entity_Id; Mech_Name : Node_Id) is Class : Node_Id; Param : Node_Id; + Mech_Name_Id : Name_Id; procedure Bad_Class; -- Signal bad descriptor class name @@ -4655,7 +4706,8 @@ package body Sem_Prag is ("mechanism for & has already been set", Mech_Name, Ent); end if; - -- MECHANISM_NAME ::= value | reference | descriptor + -- MECHANISM_NAME ::= value | reference | descriptor | + -- short_descriptor if Nkind (Mech_Name) = N_Identifier then if Chars (Mech_Name) = Name_Value then @@ -4671,6 +4723,11 @@ package body Sem_Prag is Set_Mechanism (Ent, By_Descriptor); return; + elsif Chars (Mech_Name) = Name_Short_Descriptor then + Check_VMS (Mech_Name); + Set_Mechanism (Ent, By_Short_Descriptor); + return; + elsif Chars (Mech_Name) = Name_Copy then Error_Pragma_Arg ("bad mechanism name, Value assumed", Mech_Name); @@ -4679,22 +4736,28 @@ package body Sem_Prag is Bad_Mechanism; end if; - -- MECHANISM_NAME ::= descriptor (CLASS_NAME) + -- MECHANISM_NAME ::= descriptor (CLASS_NAME) | + -- short_descriptor (CLASS_NAME) -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca -- Note: this form is parsed as an indexed component elsif Nkind (Mech_Name) = N_Indexed_Component then + Class := First (Expressions (Mech_Name)); if Nkind (Prefix (Mech_Name)) /= N_Identifier - or else Chars (Prefix (Mech_Name)) /= Name_Descriptor - or else Present (Next (Class)) + or else not (Chars (Prefix (Mech_Name)) = Name_Descriptor or else + Chars (Prefix (Mech_Name)) = Name_Short_Descriptor) + or else Present (Next (Class)) then Bad_Mechanism; + else + Mech_Name_Id := Chars (Prefix (Mech_Name)); end if; - -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) + -- MECHANISM_NAME ::= descriptor (Class => CLASS_NAME) | + -- short_descriptor (Class => CLASS_NAME) -- CLASS_NAME ::= ubs | ubsb | uba | s | sb | a | nca -- Note: this form is parsed as a function call @@ -4704,7 +4767,8 @@ package body Sem_Prag is Param := First (Parameter_Associations (Mech_Name)); if Nkind (Name (Mech_Name)) /= N_Identifier - or else Chars (Name (Mech_Name)) /= Name_Descriptor + or else not (Chars (Name (Mech_Name)) = Name_Descriptor or else + Chars (Name (Mech_Name)) = Name_Short_Descriptor) or else Present (Next (Param)) or else No (Selector_Name (Param)) or else Chars (Selector_Name (Param)) /= Name_Class @@ -4712,6 +4776,7 @@ package body Sem_Prag is Bad_Mechanism; else Class := Explicit_Actual_Parameter (Param); + Mech_Name_Id := Chars (Name (Mech_Name)); end if; else @@ -4725,27 +4790,76 @@ package body Sem_Prag is if Nkind (Class) /= N_Identifier then Bad_Class; - elsif Chars (Class) = Name_UBS then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_UBS + then Set_Mechanism (Ent, By_Descriptor_UBS); - elsif Chars (Class) = Name_UBSB then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_UBSB + then Set_Mechanism (Ent, By_Descriptor_UBSB); - elsif Chars (Class) = Name_UBA then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_UBA + then Set_Mechanism (Ent, By_Descriptor_UBA); - elsif Chars (Class) = Name_S then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_S + then Set_Mechanism (Ent, By_Descriptor_S); - elsif Chars (Class) = Name_SB then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_SB + then Set_Mechanism (Ent, By_Descriptor_SB); - elsif Chars (Class) = Name_A then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_A + then Set_Mechanism (Ent, By_Descriptor_A); - elsif Chars (Class) = Name_NCA then + elsif Mech_Name_Id = Name_Descriptor + and then Chars (Class) = Name_NCA + then Set_Mechanism (Ent, By_Descriptor_NCA); + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_UBS + then + Set_Mechanism (Ent, By_Short_Descriptor_UBS); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_UBSB + then + Set_Mechanism (Ent, By_Short_Descriptor_UBSB); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_UBA + then + Set_Mechanism (Ent, By_Short_Descriptor_UBA); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_S + then + Set_Mechanism (Ent, By_Short_Descriptor_S); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_SB + then + Set_Mechanism (Ent, By_Short_Descriptor_SB); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_A + then + Set_Mechanism (Ent, By_Short_Descriptor_A); + + elsif Mech_Name_Id = Name_Short_Descriptor + and then Chars (Class) = Name_NCA + then + Set_Mechanism (Ent, By_Short_Descriptor_NCA); + else Bad_Class; end if; @@ -5540,18 +5654,6 @@ package body Sem_Prag is end if; end C_Pass_By_Copy; - ----------------------- - -- Canonical_Streams -- - ----------------------- - - -- pragma Canonical_Streams; - - when Pragma_Canonical_Streams => - GNAT_Pragma; - Check_Arg_Count (0); - Check_Valid_Configuration_Pragma; - Canonical_Streams := True; - ----------- -- Check -- ----------- @@ -5715,11 +5817,11 @@ package body Sem_Prag is -- pragma Comment (static_string_EXPRESSION) - -- Processing for pragma Comment shares the circuitry for - -- pragma Ident. The only differences are that Ident enforces - -- a limit of 31 characters on its argument, and also enforces - -- limitations on placement for DEC compatibility. Pragma - -- Comment shares neither of these restrictions. + -- Processing for pragma Comment shares the circuitry for pragma + -- Ident. The only differences are that Ident enforces a limit of 31 + -- characters on its argument, and also enforces limitations on + -- placement for DEC compatibility. Pragma Comment shares neither of + -- these restrictions. ------------------- -- Common_Object -- @@ -5740,6 +5842,7 @@ package body Sem_Prag is -- (boolean_EXPRESSION, static_string_EXPRESSION); when Pragma_Compile_Time_Error => + GNAT_Pragma; Process_Compile_Time_Warning_Or_Error; -------------------------- @@ -5750,6 +5853,7 @@ package body Sem_Prag is -- (boolean_EXPRESSION, static_string_EXPRESSION); when Pragma_Compile_Time_Warning => + GNAT_Pragma; Process_Compile_Time_Warning_Or_Error; ------------------- @@ -6124,6 +6228,8 @@ package body Sem_Prag is when Pragma_CPP_Virtual => CPP_Virtual : declare begin + GNAT_Pragma; + if Warn_On_Obsolescent_Feature then Error_Msg_N ("'G'N'A'T pragma cpp'_virtual is now obsolete and has " & @@ -6137,6 +6243,8 @@ package body Sem_Prag is when Pragma_CPP_Vtable => CPP_Vtable : declare begin + GNAT_Pragma; + if Warn_On_Obsolescent_Feature then Error_Msg_N ("'G'N'A'T pragma cpp'_vtable is now obsolete and has " & @@ -6656,6 +6764,8 @@ package body Sem_Prag is Code : Node_Id renames Args (4); begin + GNAT_Pragma; + if Inside_A_Generic then Error_Pragma ("pragma% cannot be used for generic entities"); end if; @@ -7125,6 +7235,7 @@ package body Sem_Prag is Typ : Entity_Id; begin + GNAT_Pragma; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); @@ -7458,6 +7569,7 @@ package body Sem_Prag is Code : Node_Id renames Args (4); begin + GNAT_Pragma; Gather_Associations (Names, Args); if Present (External) and then Present (Code) then @@ -7743,6 +7855,7 @@ package body Sem_Prag is -- pragma Inline_Always ( NAME {, NAME} ); when Pragma_Inline_Always => + GNAT_Pragma; Process_Inline (True); -------------------- @@ -7752,6 +7865,7 @@ package body Sem_Prag is -- pragma Inline_Generic (NAME {, NAME}); when Pragma_Inline_Generic => + GNAT_Pragma; Process_Generic_List; ---------------------- @@ -8782,6 +8896,7 @@ package body Sem_Prag is -- it was misplaced. when Pragma_No_Body => + GNAT_Pragma; Pragma_Misplaced; --------------- @@ -8848,13 +8963,43 @@ package body Sem_Prag is end loop; end No_Return; + ----------------- + -- No_Run_Time -- + ----------------- + + -- pragma No_Run_Time; + + -- Note: this pragma is retained for backwards compatibility. + -- See body of Rtsfind for full details on its handling. + + when Pragma_No_Run_Time => + GNAT_Pragma; + Check_Valid_Configuration_Pragma; + Check_Arg_Count (0); + + No_Run_Time_Mode := True; + Configurable_Run_Time_Mode := True; + + -- Set Duration to 32 bits if word size is 32 + + if Ttypes.System_Word_Size = 32 then + Duration_32_Bits_On_Target := True; + end if; + + -- Set appropriate restrictions + + Set_Restriction (No_Finalization, N); + Set_Restriction (No_Exception_Handlers, N); + Set_Restriction (Max_Tasks, N, 0); + Set_Restriction (No_Tasking, N); + ------------------------ -- No_Strict_Aliasing -- ------------------------ -- pragma No_Strict_Aliasing [([Entity =>] type_LOCAL_NAME)]; - when Pragma_No_Strict_Aliasing => No_Strict_Alias : declare + when Pragma_No_Strict_Aliasing => No_Strict_Aliasing : declare E_Id : Entity_Id; begin @@ -8878,7 +9023,20 @@ package body Sem_Prag is Set_No_Strict_Aliasing (Implementation_Base_Type (E_Id)); end if; - end No_Strict_Alias; + end No_Strict_Aliasing; + + ----------------------- + -- Normalize_Scalars -- + ----------------------- + + -- pragma Normalize_Scalars; + + when Pragma_Normalize_Scalars => + Check_Ada_83_Warning; + Check_Arg_Count (0); + Check_Valid_Configuration_Pragma; + Normalize_Scalars := True; + Init_Or_Norm_Scalars := True; ----------------- -- Obsolescent -- @@ -9086,49 +9244,6 @@ package body Sem_Prag is end if; end Obsolescent; - ----------------- - -- No_Run_Time -- - ----------------- - - -- pragma No_Run_Time - - -- Note: this pragma is retained for backwards compatibility. - -- See body of Rtsfind for full details on its handling. - - when Pragma_No_Run_Time => - GNAT_Pragma; - Check_Valid_Configuration_Pragma; - Check_Arg_Count (0); - - No_Run_Time_Mode := True; - Configurable_Run_Time_Mode := True; - - -- Set Duration to 32 bits if word size is 32 - - if Ttypes.System_Word_Size = 32 then - Duration_32_Bits_On_Target := True; - end if; - - -- Set appropriate restrictions - - Set_Restriction (No_Finalization, N); - Set_Restriction (No_Exception_Handlers, N); - Set_Restriction (Max_Tasks, N, 0); - Set_Restriction (No_Tasking, N); - - ----------------------- - -- Normalize_Scalars -- - ----------------------- - - -- pragma Normalize_Scalars; - - when Pragma_Normalize_Scalars => - Check_Ada_83_Warning; - Check_Arg_Count (0); - Check_Valid_Configuration_Pragma; - Normalize_Scalars := True; - Init_Or_Norm_Scalars := True; - -------------- -- Optimize -- -------------- @@ -9365,19 +9480,6 @@ package body Sem_Prag is end if; end Preelab_Init; - ------------- - -- Polling -- - ------------- - - -- pragma Polling (ON | OFF); - - when Pragma_Polling => - GNAT_Pragma; - Check_Arg_Count (1); - Check_No_Identifiers; - Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); - Polling_Required := (Chars (Expression (Arg1)) = Name_On); - -------------------- -- Persistent_BSS -- -------------------- @@ -9436,6 +9538,19 @@ package body Sem_Prag is end if; end Persistent_BSS; + ------------- + -- Polling -- + ------------- + + -- pragma Polling (ON | OFF); + + when Pragma_Polling => + GNAT_Pragma; + Check_Arg_Count (1); + Check_No_Identifiers; + Check_Arg_Is_One_Of (Arg1, Name_On, Name_Off); + Polling_Required := (Chars (Expression (Arg1)) = Name_On); + ------------------- -- Postcondition -- ------------------- @@ -10952,6 +11067,7 @@ package body Sem_Prag is -- or the identifier GCC, no other identifiers are acceptable. when Pragma_System_Name => + GNAT_Pragma; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_One_Of (Arg1, Name_Gcc, Name_Gnat); @@ -11200,7 +11316,7 @@ package body Sem_Prag is Variant : Node_Id; begin - GNAT_Pragma; + Ada_2005_Pragma; Check_No_Identifiers; Check_Arg_Count (1); Check_Arg_Is_Local_Name (Arg1); @@ -11567,7 +11683,7 @@ package body Sem_Prag is -- pragma Unsuppress (IDENTIFIER [, [On =>] NAME]); when Pragma_Unsuppress => - GNAT_Pragma; + Ada_2005_Pragma; Process_Suppress_Unsuppress (False); ------------------- @@ -11891,6 +12007,7 @@ package body Sem_Prag is -- pragma Wide_Character_Encoding (IDENTIFIER); when Pragma_Wide_Character_Encoding => + GNAT_Pragma; -- Nothing to do, handled in parser. Note that we do not enforce -- configuration pragma placement, this pragma can appear at any @@ -12093,7 +12210,6 @@ package body Sem_Prag is Pragma_Atomic => 0, Pragma_Atomic_Components => 0, Pragma_Attach_Handler => -1, - Pragma_Canonical_Streams => -1, Pragma_Check => 99, Pragma_Check_Name => 0, Pragma_Check_Policy => 0, |