From 80c2c20282aae97e232df885461b828d5d6573b0 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Tue, 25 Feb 2014 16:35:36 +0100 Subject: [multiple changes] 2014-02-25 Robert Dewar * errout.adb: Various changes for better msgs for anonmous access subprogram types. * erroutc.ads, erroutc.adb (Buffer_Ends_With): Version with character argument. (Buffer_Remove): Version with character argument. * sem_attr.adb (Resolve_Attribute, case Access): Better handling of mismatching conventions for access-to-subprogram case. * sem_prag.adb (Set_Convention_From_Pragma): Deal with anonymous access types in record. * sem_util.ads, sem_util.adb (Set_Convention): Handle anonymous access types, including in records. 2014-02-25 Doug Rupp * sigtramp-ppcvxw.c, sigtramp.h, sigtramp-armvxw.c: Comment enhancements and corrections. 2014-02-25 Robert Dewar * gnat_rm.texi: New section "Conventions and Anonymous Access Types" From-SVN: r208143 --- gcc/ada/sem_util.adb | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'gcc/ada/sem_util.adb') diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ad42534..791bc2e 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -15631,6 +15631,52 @@ package body Sem_Util is then Set_Can_Use_Internal_Rep (E, False); end if; + + -- If E is an object or component, and the type of E is an anonymous + -- access type with no convention set, then also set the convention of + -- the anonymous access type. We do not do this for anonymous protected + -- types, since protected types always have the default convention. + + if Present (Etype (E)) + and then (Is_Object (E) + or else Ekind (E) = E_Component + + -- Allow E_Void (happens for pragma Convention appearing + -- in the middle of a record applying to a component) + + or else Ekind (E) = E_Void) + then + declare + Typ : constant Entity_Id := Etype (E); + + begin + if Ekind_In (Typ, E_Anonymous_Access_Type, + E_Anonymous_Access_Subprogram_Type) + and then not Has_Convention_Pragma (Typ) + then + Basic_Set_Convention (Typ, Val); + Set_Has_Convention_Pragma (Typ); + + -- And for the access subprogram type, deal similarly with the + -- designated E_Subprogram_Type if it is also internal (which + -- it always is?) + + if Ekind (Typ) = E_Anonymous_Access_Subprogram_Type then + declare + Dtype : constant Entity_Id := Designated_Type (Typ); + begin + if Ekind (Dtype) = E_Subprogram_Type + and then Is_Itype (Dtype) + and then not Has_Convention_Pragma (Dtype) + then + Basic_Set_Convention (Dtype, Val); + Set_Has_Convention_Pragma (Dtype); + end if; + end; + end if; + end if; + end; + end if; end Set_Convention; ------------------------ -- cgit v1.1