exp_aggr.adb (Component_Check): Extend the check that verifies that the aggregate...
authorJavier Miranda <miranda@adacore.com>
Thu, 21 Apr 2016 09:18:57 +0000 (09:18 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 21 Apr 2016 09:18:57 +0000 (11:18 +0200)
2016-04-21  Javier Miranda  <miranda@adacore.com>

* exp_aggr.adb (Component_Check): Extend
the check that verifies that the aggregate has no function
calls to handle transformations performed by the frontend.
(Ultimate_Original_Expression): New subprogram.

From-SVN: r235321

gcc/ada/ChangeLog
gcc/ada/exp_aggr.adb

index c06c004f2c9f4ae2ba6a4bd6a2ab515ae52c5ca8..2fc027e453fa8d19f950ab7f4ed821e75d003522 100644 (file)
@@ -1,3 +1,10 @@
+2016-04-21  Javier Miranda  <miranda@adacore.com>
+
+       * exp_aggr.adb (Component_Check): Extend
+       the check that verifies that the aggregate has no function
+       calls to handle transformations performed by the frontend.
+       (Ultimate_Original_Expression): New subprogram.
+
 2016-04-21  Philippe Gil  <gil@adacore.com>
 
        * krunch.adb (Krunch): Fix krunching of i-java.
index efaee5e67667ad755bb6f97070ca8f463b5034c7..6d6e1a2526312e2c45c5e6108304052c1c84a2bb 100644 (file)
@@ -564,6 +564,30 @@ package body Exp_Aggr is
       ---------------------
 
       function Component_Check (N : Node_Id; Index : Node_Id) return Boolean is
+
+         function Ultimate_Original_Expression (N : Node_Id) return Node_Id;
+         --  Given a type conversion or an unchecked type conversion N, return
+         --  its innermost original expression.
+
+         ----------------------------------
+         -- Ultimate_Original_Expression --
+         ----------------------------------
+
+         function Ultimate_Original_Expression (N : Node_Id) return Node_Id is
+            Expr : Node_Id := Original_Node (N);
+
+         begin
+            while Nkind_In (Expr, N_Type_Conversion,
+                                  N_Unchecked_Type_Conversion)
+            loop
+               Expr := Original_Node (Expression (Expr));
+            end loop;
+
+            return Expr;
+         end Ultimate_Original_Expression;
+
+         --  Local variables
+
          Expr : Node_Id;
 
       begin
@@ -617,7 +641,10 @@ package body Exp_Aggr is
 
             --  Checks 12: (no function call)
 
-            if Modify_Tree_For_C and then Nkind (Expr) = N_Function_Call then
+            if Modify_Tree_For_C
+              and then
+                Nkind (Ultimate_Original_Expression (Expr)) = N_Function_Call
+            then
                return False;
             end if;