]> gcc.gnu.org Git - gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 22 Jan 2014 16:42:55 +0000 (17:42 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 22 Jan 2014 16:42:55 +0000 (17:42 +0100)
2014-01-22  Robert Dewar  <dewar@adacore.com>

* debug.adb, exp_ch4.adb, erroutc.adb: Minor reformatting.

2014-01-22  Thomas Quinot  <quinot@adacore.com>

* sem_ch7.adb, sem_ch8.adb, exp_ch3.adb: Minor reformatting.

2014-01-22  Thomas Quinot  <quinot@adacore.com>

* sem_ch3.adb (Analyze_Object_Declaration): For a constant
declaration initialized with a function call, whose type
has variable size, need to remove side effects so that the
initialization expression becomes a dereference of a temporary
reference to the function result.

From-SVN: r206928

gcc/ada/ChangeLog
gcc/ada/debug.adb
gcc/ada/erroutc.adb
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch4.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch7.adb
gcc/ada/sem_ch8.adb

index 1cb84d207be6d8b5a424824936ff36a5193f72e4..44ab1e956eb0fdd43edf3effe7547899afe47d83 100644 (file)
@@ -1,3 +1,19 @@
+2014-01-22  Robert Dewar  <dewar@adacore.com>
+
+       * debug.adb, exp_ch4.adb, erroutc.adb: Minor reformatting.
+
+2014-01-22  Thomas Quinot  <quinot@adacore.com>
+
+       * sem_ch7.adb, sem_ch8.adb, exp_ch3.adb: Minor reformatting.
+
+2014-01-22  Thomas Quinot  <quinot@adacore.com>
+
+       * sem_ch3.adb (Analyze_Object_Declaration): For a constant
+       declaration initialized with a function call, whose type
+       has variable size, need to remove side effects so that the
+       initialization expression becomes a dereference of a temporary
+       reference to the function result.
+
 2014-01-22  Yannick Moy  <moy@adacore.com>
 
        * errout.adb (Initialize): Remove trick to add dummy entry
index 4cc8febb8888ba7a638dc6e29786aef12d728c55..b1c17f8cd42cc8074b71c19c315a2965efbeb1da 100644 (file)
@@ -596,7 +596,10 @@ package body Debug is
 
    --  d.E  Turn selected errors into warnings. This debug switch causes a
    --       specific set of error messages into warnings. Setting this switch
-   --       causes Opt.Error_To_Warning to be set to True.
+   --       causes Opt.Error_To_Warning to be set to True. Right now the only
+   --       error affected is the case of overlapping subprogram parameters
+   --       which has become illegal in Ada 2012, but only generates a warning
+   --       in earlier versions of Ada.
 
    --  d.F  Sets GNATprove_Mode to True. This allows debugging the frontend in
    --       the special mode used by GNATprove.
index d5497d6da6b885cc87600597473e991bf2a5a306..63aea28e86ade3bbd39db455e9a360afcb68b4cc 100644 (file)
@@ -1180,26 +1180,27 @@ package body Erroutc is
         and then not GNATprove_Mode
       then
          return;
+      end if;
 
       --  If last entry in table already covers us, this is a redundant pragma
       --  Warnings (Off) and can be ignored.
 
-      elsif Warnings.Last >= Warnings.First
+      if Warnings.Last >= Warnings.First
         and then Warnings.Table (Warnings.Last).Start <= Loc
         and then Loc <= Warnings.Table (Warnings.Last).Stop
       then
          return;
+      end if;
 
-      --  Otherwise establish a new entry, extending from the location of the
-      --  pragma to the end of the current source file. This ending point will
-      --  be adjusted by a subsequent pragma Warnings (On).
+      --  If none of those special conditions holds, establish a new entry,
+      --  extending from the location of the pragma to the end of the current
+      --  source file. This ending point will be adjusted by a subsequent
+      --  corresponding pragma Warnings (On).
 
-      else
-         Warnings.Increment_Last;
-         Warnings.Table (Warnings.Last).Start := Loc;
-         Warnings.Table (Warnings.Last).Stop :=
-           Source_Last (Current_Source_File);
-      end if;
+      Warnings.Increment_Last;
+      Warnings.Table (Warnings.Last).Start := Loc;
+      Warnings.Table (Warnings.Last).Stop :=
+        Source_Last (Current_Source_File);
    end Set_Warnings_Mode_Off;
 
    --------------------------
@@ -1223,11 +1224,12 @@ package body Erroutc is
         and then not GNATprove_Mode
       then
          return;
+      end if;
 
       --  If the last entry in the warnings table covers this pragma, then
       --  we adjust the end point appropriately.
 
-      elsif Warnings.Last >= Warnings.First
+      if Warnings.Last >= Warnings.First
         and then Warnings.Table (Warnings.Last).Start <= Loc
         and then Loc <= Warnings.Table (Warnings.Last).Stop
       then
index ce7f01fb2d0eea3161c7581e2df670dd9a13f368..d055831e34b8cf4ee1620ee7d813bba67104fb92 100644 (file)
@@ -5561,7 +5561,7 @@ package body Exp_Ch3 is
                   Apply_Constraint_Check (Expr, Typ);
 
                   --  If the expression has been marked as requiring a range
-                  --  generate it now and reset the flag.
+                  --  check, generate it now and reset the flag.
 
                   if Do_Range_Check (Expr) then
                      Set_Do_Range_Check (Expr, False);
index 03dc4fdccc4421b2a8c4e4772a93ef7183d84de6..97368c09acc56860f5dbcdb8bd121bb571621fc4 100644 (file)
@@ -7330,7 +7330,6 @@ package body Exp_Ch4 is
          declare
             Bt : constant Entity_Id := Root_Type (Underlying_Type (Bastyp));
             Et : constant Entity_Id := Root_Type (Underlying_Type (Exptyp));
-
          begin
             Rewrite (N,
               Unchecked_Convert_To (Typ,
@@ -7610,7 +7609,7 @@ package body Exp_Ch4 is
       then
          Rewrite (N,
            Make_Function_Call (Loc,
-             Name => New_Reference_To (RTE (Rent), Loc),
+             Name                   => New_Reference_To (RTE (Rent), Loc),
              Parameter_Associations => New_List (Base, Exp)));
 
       --  Otherwise we have to introduce conversions (conversions are also
index 74fc6639c61cd71a5571ef8e5d1b881f7e5c61c1..30c37487507b04ff470e986f8ad89d5d41ed81cf 100644 (file)
@@ -2991,6 +2991,11 @@ package body Sem_Ch3 is
       --  or a variant record type is encountered, Check_Restrictions is called
       --  indicating the count is unknown.
 
+      function Has_Unconstrained_Elements (T : Entity_Id) return Boolean;
+      --  True if T has discriminants and is unconstrained, or is an array
+      --  type whose element type Has_Unconstrained_Elements. Shouldn't this
+      --  be in sem_util???
+
       -----------------
       -- Count_Tasks --
       -----------------
@@ -3045,6 +3050,24 @@ package body Sem_Ch3 is
          end if;
       end Count_Tasks;
 
+      --------------------------------
+      -- Has_Unconstrained_Elements --
+      --------------------------------
+
+      function Has_Unconstrained_Elements (T : Entity_Id) return Boolean is
+         U_T : constant Entity_Id := Underlying_Type (T);
+      begin
+         if No (U_T) then
+            return False;
+         elsif Is_Record_Type (U_T) then
+            return Has_Discriminants (U_T) and then not Is_Constrained (U_T);
+         elsif Is_Array_Type (U_T) then
+            return Has_Unconstrained_Elements (Component_Type (U_T));
+         else
+            return False;
+         end if;
+      end Has_Unconstrained_Elements;
+
    --  Start of processing for Analyze_Object_Declaration
 
    begin
@@ -3647,16 +3670,15 @@ package body Sem_Ch3 is
 
          Rewrite (Object_Definition (N), New_Occurrence_Of (Act_T, Loc));
 
-      elsif Present (Underlying_Type (T))
-        and then not Is_Constrained (Underlying_Type (T))
-        and then Has_Discriminants (Underlying_Type (T))
-        and then Nkind (E) = N_Function_Call
+      elsif Nkind (E) = N_Function_Call
         and then Constant_Present (N)
+        and then Has_Unconstrained_Elements (Etype (E))
       then
          --  The back-end has problems with constants of a discriminated type
          --  with defaults, if the initial value is a function call. We
-         --  generate an intermediate temporary for the result of the call.
-         --  It is unclear why this should make it acceptable to gcc. ???
+         --  generate an intermediate temporary that will receive a reference
+         --  to the result of the call. The initialization expression then
+         --  becomes a dereference of that temporary.
 
          Remove_Side_Effects (E);
 
index 322785afb743eff78144d1a3c61d18b7198d22ad..5ae4aa360dd178d2f05cc52a918286c54a380a97 100644 (file)
@@ -2,7 +2,7 @@
 --                                                                          --
 --                         GNAT COMPILER COMPONENTS                         --
 --                                                                          --
---                              S E M . C H 7                               --
+--                              S E M _ C H 7                               --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
index a766866dd4683a6806212d068c17c7ade2a83592..b44d4e0f94a80f1c7ae3bd465eee70f79bead1e2 100644 (file)
@@ -2,7 +2,7 @@
 --                                                                          --
 --                         GNAT COMPILER COMPONENTS                         --
 --                                                                          --
---                              S E M . C H 8                               --
+--                              S E M _ C H 8                               --
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
This page took 0.098177 seconds and 5 git commands to generate.