2011-08-04 Yannick Moy <moy@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Aug 2011 12:27:40 +0000 (12:27 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Aug 2011 12:27:40 +0000 (12:27 +0000)
* 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  <kirtchev@adacore.com>

* 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  <moy@adacore.com>

* 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  <schonberg@adacore.com>

* gnat_rm.texi: Ravenscar does not prohibit dependence on
Unchecked_Conversion and Unchecked_Deallocation.

2011-08-04  Thomas Quinot  <quinot@adacore.com>

* make.adb: Minor reformatting.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177371 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/exp_ch7.adb
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads
gcc/ada/gnat_rm.texi
gcc/ada/make.adb
gcc/ada/par-ch4.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch6.adb

index 00681af..98548d9 100644 (file)
@@ -1,3 +1,38 @@
+2011-08-04  Yannick Moy  <moy@adacore.com>
+
+       * 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  <kirtchev@adacore.com>
+
+       * 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  <moy@adacore.com>
+
+       * 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  <schonberg@adacore.com>
+
+       * gnat_rm.texi: Ravenscar does not prohibit dependence on
+       Unchecked_Conversion and Unchecked_Deallocation.
+
+2011-08-04  Thomas Quinot  <quinot@adacore.com>
+
+       * make.adb: Minor reformatting.
+
 2011-08-04  Emmanuel Briot  <briot@adacore.com>
 
        * prj.adb, prj.ads, makeutl.adb (Complete_Mains): search for the
index 5dad689..357f9ef 100644 (file)
@@ -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)) =
index aaf7e3c..83682e7 100644 (file)
@@ -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 --
    ----------------------------
index 08ffc75..67cdceb 100644 (file)
@@ -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.
index 2464fc4..d1f2b8c 100644 (file)
@@ -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
 
index b987462..93f6071 100644 (file)
@@ -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
index f2fc765..125a9c4 100644 (file)
@@ -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;
 
index 0e58333..5a28908 100644 (file)
@@ -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;
index b3df5cf..c11c6e8 100644 (file)
@@ -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));