summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-03 09:53:11 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2011-08-03 09:53:11 +0000
commit4278abe43558660ecf4a08ac194843f1dfc348df (patch)
tree54d88e5f353bae2cfe465967b5729b917f1aceee
parentb5214f00570f7d501a7a1b21a5850b3b7cf6c00e (diff)
downloadgcc-4278abe43558660ecf4a08ac194843f1dfc348df.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177254 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/inline.adb7
-rw-r--r--gcc/ada/sem_res.adb40
3 files changed, 43 insertions, 11 deletions
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 <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.
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);