From 410abeeb0dde4aa71e47a507aa517ff4a4dbb6a1 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 8 Sep 2017 13:41:58 +0000 Subject: [PATCH] exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for access types. 2017-09-08 Eric Botcazou * exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for access types. From-SVN: r251896 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/exp_aggr.adb | 28 ++++++++++++++++++++++------ 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 + + * exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for + access types. + 2017-09-08 Bob Duff * 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); -- 2.30.2