exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for access types.
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 8 Sep 2017 13:41:58 +0000 (13:41 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 8 Sep 2017 13:41:58 +0000 (15:41 +0200)
2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>

* exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for
access types.

From-SVN: r251896

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

index 784d87936dd0765ec63941fd6484d7168e6e6e53..2302293f545c22f1ed8593a1dc7e6627d2433e58 100644 (file)
@@ -1,3 +1,8 @@
+2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for
+       access types.
+
 2017-09-08  Bob Duff  <duff@adacore.com>
 
        * par-prag.adb, sem_prag.adb, snames.ads-tmpl: Implement pragma
index 04fa866b73b4d08cbd0e484ffd4736d7dc5502d8..2fa0dc52b7ae8682c2a3c8109b8903efc6e550ab 100644 (file)
@@ -4971,16 +4971,32 @@ package body Exp_Aggr is
             return False;
          end if;
 
-         --  All elementary types are supported except for fat pointers
-         --  because they are not really elementary for the backend.
+         --  All elementary types are supported
 
-         if not Is_Elementary_Type (Ctyp)
-           or else (Is_Access_Type (Ctyp)
-                     and then Esize (Ctyp) /= System_Address_Size)
-         then
+         if not Is_Elementary_Type (Ctyp) then
             return False;
          end if;
 
+         --  However access types need to be dealt with specially
+
+         if Is_Access_Type (Ctyp) then
+
+            --  Fat pointers are rejected as they are not really elementary
+            --  for the backend.
+
+            if Esize (Ctyp) /= System_Address_Size then
+               return False;
+            end if;
+
+            --  The supported expressions are NULL and constants, others are
+            --  rejected upfront to avoid being analyzed below, which can be
+            --  problematic for some of them, for example allocators.
+
+            if Nkind (Expr) /= N_Null and then not Is_Entity_Name (Expr) then
+               return False;
+            end if;
+         end if;
+
          --  The expression needs to be analyzed if True is returned
 
          Analyze_And_Resolve (Expr, Ctyp);