From: Arnaud Charlet Date: Thu, 4 Aug 2011 12:27:40 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d395256d71921f464153393f04ef688f1eab209;p=gcc.git [multiple changes] 2011-08-04 Yannick Moy * par-ch4.adb (P_Primary): preferentially issue an error message about a missing parenthesis arount a conditional or case expression in Ada 2012 mode, if we detect that the alignment is not correct for a statement. 2011-08-04 Hristian Kirtchev * exp_ch7.adb (Process_Declarations): Do not consider the result of a tag-to-class-wide conversion as needing finalization actions. * exp_util.adb (Has_Controlled_Objects): Do not consider the result of a tag-to-class-wide conversion as needing finalization actions. (Is_Finalizable_Transient): The result of a tag-to-class-wide conversion does not need finalization actions. (Is_Tag_To_CW_Conversion): New routine. * exp_util.ads (Is_Tag_To_CW_Conversion): New routine. Determines whether an object is the result of a tag-to-class-wide conversion. 2011-08-04 Yannick Moy * sem_ch13.adb (Analyze_Aspect_Specifications): correct order in which the left-hand-side and right-hand-side of a conjunct are inserted when translating a pre- or postcondition * sem_ch6.adb: Correct typo in comment 2011-08-04 Ed Schonberg * gnat_rm.texi: Ravenscar does not prohibit dependence on Unchecked_Conversion and Unchecked_Deallocation. 2011-08-04 Thomas Quinot * make.adb: Minor reformatting. From-SVN: r177371 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 00681af1074..98548d94828 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,38 @@ +2011-08-04 Yannick Moy + + * par-ch4.adb (P_Primary): preferentially issue an error message about + a missing parenthesis arount a conditional or case expression in Ada + 2012 mode, if we detect that the alignment is not correct for a + statement. + +2011-08-04 Hristian Kirtchev + + * exp_ch7.adb (Process_Declarations): Do not consider the result of a + tag-to-class-wide conversion as needing finalization actions. + * exp_util.adb (Has_Controlled_Objects): Do not consider the result of + a tag-to-class-wide conversion as needing finalization actions. + (Is_Finalizable_Transient): The result of a tag-to-class-wide + conversion does not need finalization actions. + (Is_Tag_To_CW_Conversion): New routine. + * exp_util.ads (Is_Tag_To_CW_Conversion): New routine. Determines + whether an object is the result of a tag-to-class-wide conversion. + +2011-08-04 Yannick Moy + + * sem_ch13.adb (Analyze_Aspect_Specifications): correct order in which + the left-hand-side and right-hand-side of a conjunct are inserted when + translating a pre- or postcondition + * sem_ch6.adb: Correct typo in comment + +2011-08-04 Ed Schonberg + + * gnat_rm.texi: Ravenscar does not prohibit dependence on + Unchecked_Conversion and Unchecked_Deallocation. + +2011-08-04 Thomas Quinot + + * make.adb: Minor reformatting. + 2011-08-04 Emmanuel Briot * prj.adb, prj.ads, makeutl.adb (Complete_Mains): search for the diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 5dad689c1f0..357f9ef7d1c 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -1757,12 +1757,14 @@ package body Exp_Ch7 is -- The object is of the form: -- Obj : Typ [:= Expr]; -- - -- Do not process the incomplete view of a deferred constant + -- Do not process the incomplete view of a deferred constant. + -- Do not consider tag-to-class-wide conversions. elsif not Is_Imported (Obj_Id) and then Needs_Finalization (Obj_Typ) and then not (Ekind (Obj_Id) = E_Constant and then not Has_Completion (Obj_Id)) + and then not Is_Tag_To_CW_Conversion (Obj_Id) then Processing_Actions; @@ -1785,6 +1787,9 @@ package body Exp_Ch7 is then Processing_Actions (Has_No_Init => True); + -- Processing for "hook" objects generated for controlled + -- transients declared inside an Expression_With_Actions. + elsif Is_Access_Type (Obj_Typ) and then Present (Return_Flag_Or_Transient_Decl (Obj_Id)) and then Nkind (Return_Flag_Or_Transient_Decl (Obj_Id)) = diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index aaf7e3ce6e2..83682e73652 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -2668,12 +2668,14 @@ package body Exp_Util is -- The object is of the form: -- Obj : Typ [:= Expr]; -- - -- Do not process the incomplete view of a deferred constant + -- Do not process the incomplete view of a deferred constant. Do + -- not consider tag-to-class-wide conversions. elsif not Is_Imported (Obj_Id) and then Needs_Finalization (Obj_Typ) and then not (Ekind (Obj_Id) = E_Constant and then not Has_Completion (Obj_Id)) + and then not Is_Tag_To_CW_Conversion (Obj_Id) then return True; @@ -2696,6 +2698,9 @@ package body Exp_Util is then return True; + -- Processing for "hook" objects generated for controlled + -- transients declared inside an Expression_With_Actions. + elsif Is_Access_Type (Obj_Typ) and then Present (Return_Flag_Or_Transient_Decl (Obj_Id)) and then Nkind (Return_Flag_Or_Transient_Decl (Obj_Id)) = @@ -3968,11 +3973,6 @@ package body Exp_Util is and then not Is_Allocated (Obj_Id) - -- Do not consider renamed transient objects because the act of - -- renaming extends the object's lifetime. - - and then not Is_Renamed (Obj_Id, Decl) - -- If the transient object is a pointer, check that it is not -- initialized by a function which returns a pointer or acts as a -- renaming of another pointer. @@ -3984,7 +3984,16 @@ package body Exp_Util is -- Do not consider transient objects which act as indirect aliases of -- build-in-place function results. - and then not Initialized_By_Aliased_BIP_Func_Call (Obj_Id); + and then not Initialized_By_Aliased_BIP_Func_Call (Obj_Id) + + -- Do not consider renamed transient objects because the act of + -- renaming extends the object's lifetime. + + and then not Is_Renamed (Obj_Id, Decl) + + -- Do not consider conversions of tags to class-wide types + + and then not Is_Tag_To_CW_Conversion (Obj_Id); end Is_Finalizable_Transient; --------------------------------- @@ -4502,6 +4511,21 @@ package body Exp_Util is end if; end Is_Renamed_Object; + ----------------------------- + -- Is_Tag_To_CW_Conversion -- + ----------------------------- + + function Is_Tag_To_CW_Conversion (Obj_Id : Entity_Id) return Boolean is + Expr : constant Node_Id := Expression (Parent (Obj_Id)); + + begin + return + Is_Class_Wide_Type (Etype (Obj_Id)) + and then Present (Expr) + and then Nkind (Expr) = N_Unchecked_Type_Conversion + and then Etype (Expression (Expr)) = RTE (RE_Tag); + end Is_Tag_To_CW_Conversion; + ---------------------------- -- Is_Untagged_Derivation -- ---------------------------- diff --git a/gcc/ada/exp_util.ads b/gcc/ada/exp_util.ads index 08ffc75208d..67cdceba0b9 100644 --- a/gcc/ada/exp_util.ads +++ b/gcc/ada/exp_util.ads @@ -594,6 +594,10 @@ package Exp_Util is -- We consider that a (1 .. 2) is a renamed object since it is the prefix -- of the name in the renaming declaration. + function Is_Tag_To_CW_Conversion (Obj_Id : Entity_Id) return Boolean; + -- Determine whether object Obj_Id is the result of a tag-to-class-wide + -- type conversion. + function Is_Untagged_Derivation (T : Entity_Id) return Boolean; -- Returns true if type T is not tagged and is a derived type, -- or is a private type whose completion is such a type. diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi index 2464fc4b03d..d1f2b8c6acc 100644 --- a/gcc/ada/gnat_rm.texi +++ b/gcc/ada/gnat_rm.texi @@ -4256,13 +4256,6 @@ Tasks which terminate are erroneous. Entry barrier condition expressions shall be either static boolean expressions or boolean objects which are declared in the protected type which contains the entry. - -@item No_Unchecked_Conversion -There are no semantic dependencies on the Ada.Unchecked_Conversion package. - -@item No_Unchecked_Deallocation -There are no semantic dependencies on the Ada.Unchecked_Deallocation package. - @end table @noindent diff --git a/gcc/ada/make.adb b/gcc/ada/make.adb index b987462936d..93f607125ce 100644 --- a/gcc/ada/make.adb +++ b/gcc/ada/make.adb @@ -1298,10 +1298,10 @@ package body Make is Add_Str_To_Name_Buffer (File_Name); Switches := Switches_Of - (Source_File => Name_Find, - Project => Main_Project, - In_Package => The_Package, - Allow_ALI => Program = Binder or else Program = Linker); + (Source_File => Name_Find, + Project => Main_Project, + In_Package => The_Package, + Allow_ALI => Program = Binder or else Program = Linker); if Switches.Kind = List then Program_Args := Program; @@ -1357,7 +1357,9 @@ package body Make is pragma Assert (Args'First = 1); -- Optimize the simple case where the gnatbind command line looks like - -- gnatbind -aO. -I- file.ali --into-> gnatbind file.adb + -- gnatbind -aO. -I- file.ali + -- into + -- gnatbind file.adb if Args'Length = 2 and then Args (Args'First).all = "-aO" & Normalized_CWD @@ -1494,7 +1496,7 @@ package body Make is begin -- Test whether Uname is the name of a body unit (i.e. ends - -- with %b) + -- with %b). Get_Name_String (Uname); pragma @@ -1571,12 +1573,12 @@ package body Make is -- Time stamp of the current object file Modified_Source : File_Name_Type; - -- The first source in Lib_File whose current time stamp differs - -- from that stored in Lib_File. + -- The first source in Lib_File whose current time stamp differs from + -- that stored in Lib_File. New_Spec : File_Name_Type; -- If Lib_File contains in its W (with) section a body (for a - -- subprogram) for which there exists a spec and the spec did not + -- subprogram) for which there exists a spec, and the spec did not -- appear in the Sdep section of Lib_File, New_Spec contains the file -- name of this new spec. @@ -1670,8 +1672,7 @@ package body Make is return; end if; - -- Don't take Ali file into account if it was generated with - -- errors. + -- Don't take ALI file into account if it was generated with errors if ALIs.Table (ALI).Compile_Errors then Verbose_Msg (Full_Lib_File, "had errors, must be recompiled"); @@ -1679,8 +1680,7 @@ package body Make is return; end if; - -- Don't take Ali file into account if it was generated without - -- object. + -- Don't take ALI file into account if no object was generated if Operating_Mode /= Check_Semantics and then ALIs.Table (ALI).No_Object @@ -1727,11 +1727,8 @@ package body Make is -- First, collect all the switches Collect_Arguments (Source_File, Is_Main_Source, The_Args); - Prev_Switch := Dummy_Switch; - Get_Name_String (ALIs.Table (ALI).Sfile); - Switches_To_Check.Set_Last (0); for J in 1 .. Last_Argument loop @@ -1992,8 +1989,8 @@ package body Make is Projects (J) := Proj; end loop; - -- Now check if any of the dependant sources are in - -- any of these extending projects. + -- Now check if any of the dependant sources are in any + -- of these extending projects. D_Chk : for D in ALIs.Table (ALI).First_Sdep .. @@ -5674,8 +5671,8 @@ package body Make is procedure Check_Mains is Real_Main_Project : Project_Id := No_Project; - Info : Main_Info; - Proj : Project_Id; + Info : Main_Info; + Proj : Project_Id; begin if Mains.Number_Of_Mains (Project_Tree) = 0 and then not Unique_Compile @@ -5689,6 +5686,7 @@ package body Make is -- If we have multiple mains on the command line, they need not -- belong to the root project, but they must all belong to the same -- project. + if not Unique_Compile then Mains.Reset; loop diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb index f2fc7654108..125a9c4a1e0 100644 --- a/gcc/ada/par-ch4.adb +++ b/gcc/ada/par-ch4.adb @@ -2445,9 +2445,16 @@ package body Ch4 is -- If this looks like a real if, defined as an IF appearing at -- the start of a new line, then we consider we have a missing - -- operand. - - if Token_Is_At_Start_Of_Line then + -- operand. If in Ada 2012 and the IF is not properly indented + -- for a statement, we prefer to issue a message about an ill- + -- parenthesized conditional expression. + + if Token_Is_At_Start_Of_Line + and then not + (Ada_Version >= Ada_2012 + and then Style_Check_Indentation /= 0 + and then Start_Column rem Style_Check_Indentation /= 0) + then Error_Msg_AP ("missing operand"); return Error; @@ -2471,9 +2478,16 @@ package body Ch4 is -- If this looks like a real case, defined as a CASE appearing -- the start of a new line, then we consider we have a missing - -- operand. - - if Token_Is_At_Start_Of_Line then + -- operand. If in Ada 2012 and the CASE is not properly + -- indented for a statement, we prefer to issue a message about + -- an ill-parenthesized case expression. + + if Token_Is_At_Start_Of_Line + and then not + (Ada_Version >= Ada_2012 + and then Style_Check_Indentation /= 0 + and then Start_Column rem Style_Check_Indentation /= 0) + then Error_Msg_AP ("missing operand"); return Error; diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 0e5833351ed..5a28908763a 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -1086,6 +1086,12 @@ package body Sem_Ch13 is -- we generate separate Pre/Post aspects for the separate -- clauses. Since we allow multiple pragmas, there is no -- problem in allowing multiple Pre/Post aspects internally. + -- These should be treated in reverse order (B first and + -- A second) since they are later inserted just after N in + -- the order they are treated. This way, the pragma for A + -- ends up preceding the pragma for B, which may have an + -- importance for the error raised (either constraint error + -- or precondition error). -- We do not do this for Pre'Class, since we have to put -- these conditions together in a complex OR expression @@ -1095,12 +1101,12 @@ package body Sem_Ch13 is then while Nkind (Expr) = N_And_Then loop Insert_After (Aspect, - Make_Aspect_Specification (Sloc (Right_Opnd (Expr)), + Make_Aspect_Specification (Sloc (Left_Opnd (Expr)), Identifier => Identifier (Aspect), - Expression => Relocate_Node (Right_Opnd (Expr)), + Expression => Relocate_Node (Left_Opnd (Expr)), Class_Present => Class_Present (Aspect), Split_PPC => True)); - Rewrite (Expr, Relocate_Node (Left_Opnd (Expr))); + Rewrite (Expr, Relocate_Node (Right_Opnd (Expr))); Eloc := Sloc (Expr); end loop; end if; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb index b3df5cf0f3d..c11c6e83543 100644 --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -9189,8 +9189,8 @@ package body Sem_Ch6 is -- will be executed at the start of the procedure. Note that -- this processing reverses the order of the list, which is -- what we want since new entries were chained to the head of - -- the list. There can be more then one precondition when we - -- use pragma Precondition + -- the list. There can be more than one precondition when we + -- use pragma Precondition. if not Class_Present (Prag) then Prepend (Grab_PPC, Declarations (N));