diff options
author | Ed Schonberg <schonberg@adacore.com> | 2008-05-28 17:55:20 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2008-05-28 17:55:20 +0200 |
commit | 33477fb7d8d4d1eff8a4a669265ab240377ec5af (patch) | |
tree | d3a3a6e7c59a2ff74487d36a4e13f282c67f3d27 /gcc | |
parent | 8250171ba3fa889f20d239acdc3f447476029d58 (diff) | |
download | gcc-33477fb7d8d4d1eff8a4a669265ab240377ec5af.zip gcc-33477fb7d8d4d1eff8a4a669265ab240377ec5af.tar.gz gcc-33477fb7d8d4d1eff8a4a669265ab240377ec5af.tar.bz2 |
sem_ch5.adb (Analyze_Assignment): If the name is of a local anonymous access type...
2008-05-28 Ed Schonberg <schonberg@adacore.com>
* sem_ch5.adb (Analyze_Assignment): If the name is of a local anonymous
access type, wrap the expression in a conversion to force an
accessibility check.
* sem_aggr.adb (Aggegate_Constraint_Checks): Apply conversion to force
accessibility checks even when expansion is disabled in order to
generate messages in the presence of previous errors or in
semantics-only mode.
From-SVN: r136108
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_aggr.adb | 30 | ||||
-rw-r--r-- | gcc/ada/sem_ch5.adb | 8 |
2 files changed, 23 insertions, 15 deletions
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb index c6a3e25..4f50dc0 100644 --- a/gcc/ada/sem_aggr.adb +++ b/gcc/ada/sem_aggr.adb @@ -414,6 +414,22 @@ package body Sem_Aggr is return; end if; + -- Ada 2005 (AI-230): Generate a conversion to an anonymous access + -- component's type to force the appropriate accessibility checks. + + -- Ada 2005 (AI-231): Generate conversion to the null-excluding + -- type to force the corresponding run-time check + + if Is_Access_Type (Check_Typ) + and then ((Is_Local_Anonymous_Access (Check_Typ)) + or else (Can_Never_Be_Null (Check_Typ) + and then not Can_Never_Be_Null (Exp_Typ))) + then + Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp))); + Analyze_And_Resolve (Exp, Check_Typ); + Check_Unset_Reference (Exp); + end if; + -- This is really expansion activity, so make sure that expansion -- is on and is allowed. @@ -486,20 +502,6 @@ package body Sem_Aggr is Check_Unset_Reference (Exp); end if; - -- Ada 2005 (AI-230): Generate a conversion to an anonymous access - -- component's type to force the appropriate accessibility checks. - - -- Ada 2005 (AI-231): Generate conversion to the null-excluding - -- type to force the corresponding run-time check - - elsif Is_Access_Type (Check_Typ) - and then ((Is_Local_Anonymous_Access (Check_Typ)) - or else (Can_Never_Be_Null (Check_Typ) - and then not Can_Never_Be_Null (Exp_Typ))) - then - Rewrite (Exp, Convert_To (Check_Typ, Relocate_Node (Exp))); - Analyze_And_Resolve (Exp, Check_Typ); - Check_Unset_Reference (Exp); end if; end Aggregate_Constraint_Checks; diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index e5de05b..1143941 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -582,9 +582,15 @@ package body Sem_Ch5 is -- Ada 2005 (AI-230 and AI-385): When the lhs type is an anonymous -- access type, apply an implicit conversion of the rhs to that type -- to force appropriate static and run-time accessibility checks. + -- This applies as well to anonymous access-to-subprogram types that + -- are component subtypes. if Ada_Version >= Ada_05 - and then Ekind (T1) = E_Anonymous_Access_Type + and then + Is_Access_Type (T1) + and then + (Is_Local_Anonymous_Access (T1) + or else Can_Never_Be_Null (T1)) then Rewrite (Rhs, Convert_To (T1, Relocate_Node (Rhs))); Analyze_And_Resolve (Rhs, T1); |