summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/exp_aggr.adb28
2 files changed, 27 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 784d87936dd..2302293f545 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 04fa866b73b..2fa0dc52b7a 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -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);