diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-17 16:08:28 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-02-17 16:08:28 +0000 |
commit | d844abd0f573ad8b85bf3931497dd5384ef60212 (patch) | |
tree | 79854d884bf8111343b5d92c9c4f2272801a0cb6 /gcc/ada | |
parent | 145aeaea2f669824f7c64e9115fca74e43666b55 (diff) | |
download | ppe42-gcc-d844abd0f573ad8b85bf3931497dd5384ef60212.tar.gz ppe42-gcc-d844abd0f573ad8b85bf3931497dd5384ef60212.zip |
2006-02-17 Javier Miranda <miranda@adacore.com>
* sem_res.adb (Resolve_Type_Conversion): In case of conversion to an
abstract interface type, the static analysis is not enough to know if
the interface is implemented or not by the source tagged type. Hence
we must pass the work to the expander to generate the required code to
evaluate the conversion at run-time.
(Resolve_Equality_Op): Do not apply previous
transformation if expansion is disasbled, to prevent anomalies when
locating global references in a generic unit.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111195 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_res.adb | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 1a8766ae864..1a9ab72b66a 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -4962,8 +4962,9 @@ package body Sem_Res is -- We apply the same conversion in the case one of the operands is -- a private subtype of the type of the other. - if Ekind (T) = E_Anonymous_Access_Type - or else Is_Private_Type (T) + if Expander_Active + and then (Ekind (T) = E_Anonymous_Access_Type + or else Is_Private_Type (T)) then if Etype (L) /= T then Rewrite (L, @@ -6747,45 +6748,31 @@ package body Sem_Res is Opnd_Type := Directly_Designated_Type (Opnd_Type); end if; - declare - Save_Typ : constant Entity_Id := Opnd_Type; - - begin - if Is_Class_Wide_Type (Opnd_Type) then - Opnd_Type := Etype (Opnd_Type); - end if; - - -- Handle subtypes + if Is_Class_Wide_Type (Opnd_Type) then + Opnd_Type := Etype (Opnd_Type); + end if; - if Ekind (Opnd_Type) = E_Protected_Subtype - or else Ekind (Opnd_Type) = E_Task_Subtype - then - Opnd_Type := Etype (Opnd_Type); - end if; + -- Handle subtypes - if not Interface_Present_In_Ancestor - (Typ => Opnd_Type, - Iface => Target_Type) - then - -- The static analysis is not enough to know if the - -- interface is implemented or not. Hence we must pass the - -- work to the expander to generate the required code to - -- evaluate the conversion at run-time. + if Ekind (Opnd_Type) = E_Protected_Subtype + or else Ekind (Opnd_Type) = E_Task_Subtype + then + Opnd_Type := Etype (Opnd_Type); + end if; - if Is_Class_Wide_Type (Save_Typ) - and then Is_Interface (Save_Typ) - then - Expand_Interface_Conversion (N, Is_Static => False); - else - Error_Msg_NE - ("(Ada 2005) does not implement interface }", - Operand, Target_Type); - end if; + if not Interface_Present_In_Ancestor + (Typ => Opnd_Type, + Iface => Target_Type) + then + -- The static analysis is not enough to know if the interface + -- is implemented or not. Hence we must pass the work to the + -- expander to generate the required code to evaluate the + -- conversion at run-time. - else - Expand_Interface_Conversion (N); - end if; - end; + Expand_Interface_Conversion (N, Is_Static => False); + else + Expand_Interface_Conversion (N); + end if; end if; end if; end Resolve_Type_Conversion; |