[multiple changes]
2011-12-21 Matthew Heaney <heaney@adacore.com> * a-crbtgk.adb (Generic_Conditional_Insert): Fixed incorrect comment. 2011-12-21 Ed Schonberg <schonberg@adacore.com> * sem_ch5.adb (Analyze_Iterator_Specification): If the name of an element iterator is not an entity name we introduce a local renaming declaration for it. To prevent spurious warnings on parameterless function calls that return a container, when expansion is disabled (either explicitly or because of a previous errors) the name must be marked as not coming from source. 2011-12-21 Arnaud Charlet <charlet@adacore.com> * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Separate handling in CodePeer mode and only ignore Component_Size attribute. 2011-12-21 Robert Dewar <dewar@adacore.com> * sem_ch6.adb (Process_Formals): Set proper mechanism for formals whose types have conventions Ada_Pass_By_Copy or Ada_Pass_By_Reference. From-SVN: r182584
This commit is contained in:
parent
892d824b45
commit
5ebfaacfb5
|
@ -1,3 +1,28 @@
|
||||||
|
2011-12-21 Matthew Heaney <heaney@adacore.com>
|
||||||
|
|
||||||
|
* a-crbtgk.adb (Generic_Conditional_Insert): Fixed incorrect comment.
|
||||||
|
|
||||||
|
2011-12-21 Ed Schonberg <schonberg@adacore.com>
|
||||||
|
|
||||||
|
* sem_ch5.adb (Analyze_Iterator_Specification): If the name
|
||||||
|
of an element iterator is not an entity name we introduce a
|
||||||
|
local renaming declaration for it. To prevent spurious warnings
|
||||||
|
on parameterless function calls that return a container, when
|
||||||
|
expansion is disabled (either explicitly or because of a previous
|
||||||
|
errors) the name must be marked as not coming from source.
|
||||||
|
|
||||||
|
2011-12-21 Arnaud Charlet <charlet@adacore.com>
|
||||||
|
|
||||||
|
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Separate
|
||||||
|
handling in CodePeer mode and only ignore Component_Size
|
||||||
|
attribute.
|
||||||
|
|
||||||
|
2011-12-21 Robert Dewar <dewar@adacore.com>
|
||||||
|
|
||||||
|
* sem_ch6.adb (Process_Formals): Set proper mechanism for
|
||||||
|
formals whose types have conventions Ada_Pass_By_Copy or
|
||||||
|
Ada_Pass_By_Reference.
|
||||||
|
|
||||||
2011-12-21 Arnaud Charlet <charlet@adacore.com>
|
2011-12-21 Arnaud Charlet <charlet@adacore.com>
|
||||||
|
|
||||||
* gnat1drv.adb (Gnat1Drv): Always delete old scil files in
|
* gnat1drv.adb (Gnat1Drv): Always delete old scil files in
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
-- --
|
-- --
|
||||||
-- B o d y --
|
-- B o d y --
|
||||||
-- --
|
-- --
|
||||||
-- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
|
-- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
|
||||||
-- --
|
-- --
|
||||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||||
|
@ -121,6 +121,21 @@ package body Ada.Containers.Red_Black_Trees.Generic_Keys is
|
||||||
X : Node_Access := Tree.Root;
|
X : Node_Access := Tree.Root;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
-- This is a "conditional" insertion, meaning that the insertion request
|
||||||
|
-- can "fail" in the sense that no new node is created. If the Key is
|
||||||
|
-- equivalent to an existing node, then we return the existing node and
|
||||||
|
-- Inserted is set to False. Otherwise, we allocate a new node (via
|
||||||
|
-- Insert_Post) and Inserted is set to True.
|
||||||
|
|
||||||
|
-- Note that we are testing for equivalence here, not equality. Key must
|
||||||
|
-- be strictly less than its next neighbor, and strictly greater than
|
||||||
|
-- its previous neighbor, in order for the conditional insertion to
|
||||||
|
-- succeed.
|
||||||
|
|
||||||
|
-- We search the tree to find the nearest neighbor of Key, which is
|
||||||
|
-- either the smallest node greater than Key (Inserted is True), or the
|
||||||
|
-- largest node less or equivalent to Key (Inserted is False).
|
||||||
|
|
||||||
Inserted := True;
|
Inserted := True;
|
||||||
while X /= null loop
|
while X /= null loop
|
||||||
Y := X;
|
Y := X;
|
||||||
|
@ -128,33 +143,50 @@ package body Ada.Containers.Red_Black_Trees.Generic_Keys is
|
||||||
X := (if Inserted then Ops.Left (X) else Ops.Right (X));
|
X := (if Inserted then Ops.Left (X) else Ops.Right (X));
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
-- If Inserted is True, then this means either that Tree is
|
|
||||||
-- empty, or there was a least one node (strictly) greater than
|
|
||||||
-- Key. Otherwise, it means that Key is equal to or greater than
|
|
||||||
-- every node.
|
|
||||||
|
|
||||||
if Inserted then
|
if Inserted then
|
||||||
|
|
||||||
|
-- Either Tree is empty, or Key is less than Y. If Y is the first
|
||||||
|
-- node in the tree, then there are no other nodes that we need to
|
||||||
|
-- search for, and we insert a new node into the tree.
|
||||||
|
|
||||||
if Y = Tree.First then
|
if Y = Tree.First then
|
||||||
Insert_Post (Tree, Y, True, Node);
|
Insert_Post (Tree, Y, True, Node);
|
||||||
return;
|
return;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- Y is the next nearest-neighbor of Key. We know that Key is not
|
||||||
|
-- equivalent to Y (because Key is strictly less than Y), so we move
|
||||||
|
-- to the previous node, the nearest-neighbor just smaller or
|
||||||
|
-- equivalent to Key.
|
||||||
|
|
||||||
Node := Ops.Previous (Y);
|
Node := Ops.Previous (Y);
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- Y is the previous nearest-neighbor of Key. We know that Key is not
|
||||||
|
-- less than Y, which means either that Key is equivalent to Y, or
|
||||||
|
-- greater than Y.
|
||||||
|
|
||||||
Node := Y;
|
Node := Y;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
-- Here Node has a value that is less than or equal to Key. We
|
-- Key is equivalent to or greater than Node. We must resolve which is
|
||||||
-- now have to resolve whether Key is equal to or greater than
|
-- the case, to determine whether the conditional insertion succeeds.
|
||||||
-- Node, which determines whether the insertion succeeds.
|
|
||||||
|
|
||||||
if Is_Greater_Key_Node (Key, Node) then
|
if Is_Greater_Key_Node (Key, Node) then
|
||||||
|
|
||||||
|
-- Key is strictly greater than Node, which means that Key is not
|
||||||
|
-- equivalent to Node. In this case, the insertion succeeds, and we
|
||||||
|
-- insert a new node into the tree.
|
||||||
|
|
||||||
Insert_Post (Tree, Y, Inserted, Node);
|
Insert_Post (Tree, Y, Inserted, Node);
|
||||||
Inserted := True;
|
Inserted := True;
|
||||||
return;
|
return;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- Key is equivalent to Node. This is a conditional insertion, so we do
|
||||||
|
-- not insert a new node in this case. We return the existing node and
|
||||||
|
-- report that no insertion has occurred.
|
||||||
|
|
||||||
Inserted := False;
|
Inserted := False;
|
||||||
end Generic_Conditional_Insert;
|
end Generic_Conditional_Insert;
|
||||||
|
|
||||||
|
|
|
@ -2108,11 +2108,28 @@ package body Sem_Ch13 is
|
||||||
Set_Analyzed (N, True);
|
Set_Analyzed (N, True);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
-- Process Ignore_Rep_Clauses option (we also ignore rep clauses in
|
-- Ignore some selected attributes in CodePeer mode since they are not
|
||||||
-- CodePeer mode or Alfa mode, since they are not relevant in these
|
-- relevant in this context.
|
||||||
-- contexts).
|
|
||||||
|
|
||||||
if Ignore_Rep_Clauses or CodePeer_Mode or Alfa_Mode then
|
if CodePeer_Mode then
|
||||||
|
case Id is
|
||||||
|
|
||||||
|
-- Ignore Component_Size in CodePeer mode, to avoid changing the
|
||||||
|
-- internal representation of types by implicitly packing them.
|
||||||
|
|
||||||
|
when Attribute_Component_Size =>
|
||||||
|
Rewrite (N, Make_Null_Statement (Sloc (N)));
|
||||||
|
return;
|
||||||
|
|
||||||
|
when others =>
|
||||||
|
null;
|
||||||
|
end case;
|
||||||
|
end if;
|
||||||
|
|
||||||
|
-- Process Ignore_Rep_Clauses option (we also ignore rep clauses in
|
||||||
|
-- Alfa mode, since they are not relevant in this context).
|
||||||
|
|
||||||
|
if Ignore_Rep_Clauses or Alfa_Mode then
|
||||||
case Id is
|
case Id is
|
||||||
|
|
||||||
-- The following should be ignored. They do not affect legality
|
-- The following should be ignored. They do not affect legality
|
||||||
|
|
|
@ -2257,11 +2257,17 @@ package body Sem_Ch5 is
|
||||||
begin
|
begin
|
||||||
Typ := Etype (Iter_Name);
|
Typ := Etype (Iter_Name);
|
||||||
|
|
||||||
|
-- The name in the renaming declaration may be a function call.
|
||||||
|
-- Indicate that it does not come from source, to suppress
|
||||||
|
-- spurious warnings on renamings of parameterless functions,
|
||||||
|
-- a common enough idiom in user-defined iterators.
|
||||||
|
|
||||||
Decl :=
|
Decl :=
|
||||||
Make_Object_Renaming_Declaration (Loc,
|
Make_Object_Renaming_Declaration (Loc,
|
||||||
Defining_Identifier => Id,
|
Defining_Identifier => Id,
|
||||||
Subtype_Mark => New_Occurrence_Of (Typ, Loc),
|
Subtype_Mark => New_Occurrence_Of (Typ, Loc),
|
||||||
Name => Relocate_Node (Iter_Name));
|
Name =>
|
||||||
|
New_Copy_Tree (Iter_Name, New_Sloc => Loc));
|
||||||
|
|
||||||
Insert_Actions (Parent (Parent (N)), New_List (Decl));
|
Insert_Actions (Parent (Parent (N)), New_List (Decl));
|
||||||
Rewrite (Name (N), New_Occurrence_Of (Id, Loc));
|
Rewrite (Name (N), New_Occurrence_Of (Id, Loc));
|
||||||
|
|
|
@ -9527,13 +9527,13 @@ package body Sem_Ch6 is
|
||||||
Default := Expression (Param_Spec);
|
Default := Expression (Param_Spec);
|
||||||
|
|
||||||
if Is_Scalar_Type (Etype (Default)) then
|
if Is_Scalar_Type (Etype (Default)) then
|
||||||
if Nkind
|
if Nkind (Parameter_Type (Param_Spec)) /=
|
||||||
(Parameter_Type (Param_Spec)) /= N_Access_Definition
|
N_Access_Definition
|
||||||
then
|
then
|
||||||
Formal_Type := Entity (Parameter_Type (Param_Spec));
|
Formal_Type := Entity (Parameter_Type (Param_Spec));
|
||||||
|
|
||||||
else
|
else
|
||||||
Formal_Type := Access_Definition
|
Formal_Type :=
|
||||||
|
Access_Definition
|
||||||
(Related_Nod, Parameter_Type (Param_Spec));
|
(Related_Nod, Parameter_Type (Param_Spec));
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
@ -9556,6 +9556,21 @@ package body Sem_Ch6 is
|
||||||
|
|
||||||
if Is_Aliased (Formal) then
|
if Is_Aliased (Formal) then
|
||||||
Set_Mechanism (Formal, By_Reference);
|
Set_Mechanism (Formal, By_Reference);
|
||||||
|
|
||||||
|
-- Warn if user asked this to be passed by copy
|
||||||
|
|
||||||
|
if Convention (Formal_Type) = Convention_Ada_Pass_By_Copy then
|
||||||
|
Error_Msg_N
|
||||||
|
("?cannot pass aliased parameter & by copy", Formal);
|
||||||
|
end if;
|
||||||
|
|
||||||
|
-- Force mechanism if type has Convention Ada_Pass_By_Ref/Copy
|
||||||
|
|
||||||
|
elsif Convention (Formal_Type) = Convention_Ada_Pass_By_Copy then
|
||||||
|
Set_Mechanism (Formal, By_Copy);
|
||||||
|
|
||||||
|
elsif Convention (Formal_Type) = Convention_Ada_Pass_By_Reference then
|
||||||
|
Set_Mechanism (Formal, By_Reference);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
Next (Param_Spec);
|
Next (Param_Spec);
|
||||||
|
|
Loading…
Reference in New Issue