diff options
author | Ed Schonberg <schonberg@adacore.com> | 2011-08-03 09:53:11 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-08-03 11:53:11 +0200 |
commit | 668a19bcfe171969271ab6a2702d42b83ca32f5b (patch) | |
tree | 54d88e5f353bae2cfe465967b5729b917f1aceee /gcc/ada/sem_res.adb | |
parent | 170b298986d2a6f9b9069a43db89b273640ffd31 (diff) | |
download | gcc-668a19bcfe171969271ab6a2702d42b83ca32f5b.tar.gz |
inline.adb: proper handling of init_procs.
2011-08-03 Ed Schonberg <schonberg@adacore.com>
* inline.adb: proper handling of init_procs.
* sem_res.adb (Resolve_Op_Concat_Arg): if the argument is an aggregate
and the component type is composite, this is ambiguous for predefined
concatenation, but if the node is not overloaded and the entity is a use
-defined function its profile can be used to resolve that aggregate.
From-SVN: r177254
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index ddb85a7a6d0..0acf37d57c9 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7662,25 +7662,46 @@ package body Sem_Res is Is_Comp : Boolean) is Btyp : constant Entity_Id := Base_Type (Typ); + Ctyp : constant Entity_Id := Component_Type (Typ); begin if In_Instance then if Is_Comp or else (not Is_Overloaded (Arg) and then Etype (Arg) /= Any_Composite - and then Covers (Component_Type (Typ), Etype (Arg))) + and then Covers (Ctyp, Etype (Arg))) then - Resolve (Arg, Component_Type (Typ)); + Resolve (Arg, Ctyp); else Resolve (Arg, Btyp); end if; - elsif Has_Compatible_Type (Arg, Component_Type (Typ)) then + -- If both Array & Array and Array & Component are visible, there is a + -- potential ambiguity that must be reported. + + elsif Has_Compatible_Type (Arg, Ctyp) then if Nkind (Arg) = N_Aggregate - and then Is_Composite_Type (Component_Type (Typ)) + and then Is_Composite_Type (Ctyp) then - if Is_Private_Type (Component_Type (Typ)) then + if Is_Private_Type (Ctyp) then Resolve (Arg, Btyp); + + -- If the operation is user-defined and not overloaded use its + -- profile. The operation may be a renaming, in which case it has + -- been rewritten, and we want the original profile. + + elsif not Is_Overloaded (N) + and then Comes_From_Source (Entity (Original_Node (N))) + and then Ekind (Entity (Original_Node (N))) = E_Function + then + Resolve (Arg, + Etype + (Next_Formal (First_Formal (Entity (Original_Node (N)))))); + return; + + -- Otherwise an aggregate may match both the array type and the + -- component type. + else Error_Msg_N ("ambiguous aggregate must be qualified", Arg); Set_Etype (Arg, Any_Type); @@ -7715,16 +7736,15 @@ package body Sem_Res is Arg, Component_Type (Typ)); else - Error_Msg_N - ("ambiguous operand for concatenation!", Arg); + Error_Msg_N ("ambiguous operand for concatenation!", Arg); Get_First_Interp (Arg, I, It); while Present (It.Nam) loop Error_Msg_Sloc := Sloc (It.Nam); - if Base_Type (It.Typ) = Base_Type (Typ) - or else Base_Type (It.Typ) = - Base_Type (Component_Type (Typ)) + if Base_Type (It.Typ) = Btyp + or else + Base_Type (It.Typ) = Base_Type (Ctyp) then Error_Msg_N -- CODEFIX ("\\possible interpretation#", Arg); |