2014-02-04 Gary Dismukes <dismukes@adacore.com>
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 14:32:37 +0000 (14:32 +0000)
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 4 Feb 2014 14:32:37 +0000 (14:32 +0000)
* exp_ch13.adb: Minor spelling fix.

2014-02-04  Robert Dewar  <dewar@adacore.com>

* opt.ads: Minor comment update.

2014-02-04  Robert Dewar  <dewar@adacore.com>

* exp_ch4.adb (Expand_N_Expression_With_Actions): Use Rewrite
instead of Replace.

2014-02-04  Ed Schonberg  <schonberg@adacore.com>

* sem_aggr.adb (Resolve_Array_Aggregate): Suppress warnings
on null expressions if component type is non-null, when the
corresponding association covers an empty range of index values.

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

gcc/ada/ChangeLog
gcc/ada/exp_ch13.adb
gcc/ada/exp_ch4.adb
gcc/ada/opt.ads
gcc/ada/sem_aggr.adb

index 330ff75..cab5263 100644 (file)
@@ -1,3 +1,22 @@
+2014-02-04  Gary Dismukes  <dismukes@adacore.com>
+
+       * exp_ch13.adb: Minor spelling fix.
+
+2014-02-04  Robert Dewar  <dewar@adacore.com>
+
+       * opt.ads: Minor comment update.
+
+2014-02-04  Robert Dewar  <dewar@adacore.com>
+
+       * exp_ch4.adb (Expand_N_Expression_With_Actions): Use Rewrite
+       instead of Replace.
+
+2014-02-04  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_aggr.adb (Resolve_Array_Aggregate): Suppress warnings
+       on null expressions if component type is non-null, when the
+       corresponding association covers an empty range of index values.
+
 2014-02-04  Robert Dewar  <dewar@adacore.com>
 
        * sinfo.ads: Further comments on N_Expression_With_Actions node.
index 72d3f2a..3b8d05d 100644 (file)
@@ -174,7 +174,7 @@ package body Exp_Ch13 is
                   New_Decl : Node_Id;
 
                begin
-                  --  Replace entity with temporary and renalyze
+                  --  Replace entity with temporary and reanalyze
 
                   Set_Defining_Identifier (Decl, Temp);
                   Set_Analyzed (Decl, False);
index 39a80d3..7232ec8 100644 (file)
@@ -5113,11 +5113,16 @@ package body Exp_Ch4 is
       Act := First (Actions (N));
 
       --  Deal with case where there are no actions. In this case we simply
-      --  replace the node by its expression since we don't need the actions
+      --  rewrite the node with its expression since we don't need the actions
       --  and the specification of this node does not allow a null action list.
 
+      --  Note: we use Rewrite instead of Replace, because Codepeer is using
+      --  the expanded tree and relying on being able to retrieve the original
+      --  tree in cases like this. This raises a whole lot of issues of whether
+      --  we have problems elsewhere, which will be addressed in the future???
+
       if No (Act) then
-         Replace (N, Relocate_Node (Expression (N)));
+         Rewrite (N, Relocate_Node (Expression (N)));
 
       --  Otherwise process the actions as described above
 
index 95f87e8..1b192a0 100644 (file)
@@ -1292,8 +1292,8 @@ package Opt is
 
    Sprint_Line_Limit : Nat := 72;
    --  GNAT
-   --  Limit values for chopping long lines in Sprint output, can be reset by
-   --  use of NNN parameter with -gnatG or -gnatD switches.
+   --  Limit values for chopping long lines in Cprint/Sprint output, can be
+   --  reset by use of NNN parameter with -gnatG or -gnatD switches.
 
    Stack_Checking_Enabled : Boolean := False;
    --  GNAT
index 18365fc..504ddcd 100644 (file)
@@ -1937,6 +1937,25 @@ package body Sem_Aggr is
             Errors_Posted_On_Choices : Boolean := False;
             --  Keeps track of whether any choices have semantic errors
 
+            function Empty_Range (A : Node_Id)  return Boolean;
+            --  If an association covers an empty range, some warnings on the
+            --  expression of the association can be disabled.
+
+            -----------------
+            -- Empty_Range --
+            -----------------
+
+            function Empty_Range (A : Node_Id)  return Boolean is
+               R : constant Node_Id := First (Choices (A));
+            begin
+               return No (Next (R))
+                 and then Nkind (R) = N_Range
+                 and then Compile_Time_Compare
+                            (Low_Bound (R), High_Bound (R), False) = GT;
+            end Empty_Range;
+
+         --  Start of processing for Step_2
+
          begin
             --  STEP 2 (A): Check discrete choices validity
 
@@ -2059,6 +2078,7 @@ package body Sem_Aggr is
 
                if Ada_Version >= Ada_2005
                  and then Known_Null (Expression (Assoc))
+                 and then not Empty_Range (Assoc)
                then
                   Check_Can_Never_Be_Null (Etype (N), Expression (Assoc));
                end if;
@@ -4717,16 +4737,17 @@ package body Sem_Aggr is
          --  Apply_Compile_Time_Constraint_Error here to the Expr, which might
          --  seem the more natural approach. That's because in some cases the
          --  components are rewritten, and the replacement would be missed.
+         --  We do not mark the whole aggregate as raising a constraint error,
+         --  because the association may be a null array range.
 
-         Insert_Action
-           (Compile_Time_Constraint_Error
-              (Expr,
-               "(Ada 2005) null not allowed in null-excluding component??"),
-            Make_Raise_Constraint_Error
-              (Sloc (Expr), Reason => CE_Access_Check_Failed));
-
-         --  Set proper type for bogus component (why is this needed???)
+         Error_Msg_N
+           ("(Ada 2005) null not allowed in null-excluding component??", Expr);
+         Error_Msg_N
+           ("\Constraint_Error will be raised at runtime?", Expr);
 
+         Rewrite (Expr,
+           Make_Raise_Constraint_Error
+             (Sloc (Expr), Reason => CE_Access_Check_Failed));
          Set_Etype    (Expr, Comp_Typ);
          Set_Analyzed (Expr);
       end if;