From: Ed Schonberg Date: Wed, 3 Aug 2011 09:53:11 +0000 (+0000) Subject: inline.adb: proper handling of init_procs. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=668a19bcfe171969271ab6a2702d42b83ca32f5b;p=gcc.git inline.adb: proper handling of init_procs. 2011-08-03 Ed Schonberg * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 530d52bd82c..403cfe79bff 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2011-08-03 Ed Schonberg + + * 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. + 2011-08-03 Robert Dewar * exp_ch4.adb: Minor code cleanup. diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb index c508ef4bb96..0d184dd45b2 100644 --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -344,12 +344,17 @@ package body Inline is elsif not Is_Inlined (Pack) and then (not Has_Completion (E) - or else Is_Init_Proc (E) or else Is_Expression_Function (E)) then Set_Is_Inlined (Pack); Inlined_Bodies.Increment_Last; Inlined_Bodies.Table (Inlined_Bodies.Last) := Pack; + + -- an initialization procedure should be inlined, but it does + -- not require the body of the package. + + elsif Is_Init_Proc (E) then + Set_Is_Inlined (Pack); end if; end if; end; 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);