inline.adb: proper handling of init_procs.
authorEd Schonberg <schonberg@adacore.com>
Wed, 3 Aug 2011 09:53:11 +0000 (09:53 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 3 Aug 2011 09:53:11 +0000 (11:53 +0200)
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

gcc/ada/ChangeLog
gcc/ada/inline.adb
gcc/ada/sem_res.adb

index 530d52bd82cccad8af16b3ae421ef655dbdf2c06..403cfe79bffef25fb8b45a217d6b9704f3f26b62 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-03  Ed Schonberg  <schonberg@adacore.com>
+
+       * 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  <dewar@adacore.com>
 
        * exp_ch4.adb: Minor code cleanup.
index c508ef4bb96a77099212a27ab01c1b1f784ddd2f..0d184dd45b22691834819a30e6119bb7f6cee2c1 100644 (file)
@@ -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;
index ddb85a7a6d04d3ee8943d78ea11e0cdd29bff5bb..0acf37d57c9ced88853a2c9bfa1a56aff0d883b1 100644 (file)
@@ -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);