diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-06 19:24:49 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-06 19:24:49 +0000 |
commit | e3c8326394dd0c0e89ecb0773fadfb226bd4e523 (patch) | |
tree | 9c94e0d985fc138c19bf5450274084c744d41e82 /gcc/ada/a-coorse.adb | |
parent | 498af5fea6b9cfd3d66b5212cf0768ca9427185a (diff) | |
download | gcc-e3c8326394dd0c0e89ecb0773fadfb226bd4e523.tar.gz |
2011-10-06 Robert Dewar <dewar@adacore.com>
* a-ciorse.adb, a-cihase.adb, a-cihase.ads, a-coorse.adb,
a-cborse.adb, a-comutr.adb, a-ciorma.adb, a-cbmutr.adb,
a-cbmutr.ads, a-cbhase.adb, a-cbhase.ads: Minor reformatting and code
reorganization (use conditional expressions).
2011-10-06 Robert Dewar <dewar@adacore.com>
* sem_res.adb (Resolve_Arithmetic_Op): Fix bad warning for
floating divide by zero.
2011-10-06 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb: Limited interfaces that are not immutably limited
are OK in return statements.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@179629 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/a-coorse.adb')
-rw-r--r-- | gcc/ada/a-coorse.adb | 153 |
1 files changed, 41 insertions, 112 deletions
diff --git a/gcc/ada/a-coorse.adb b/gcc/ada/a-coorse.adb index d52ed67c9a0..915eed62117 100644 --- a/gcc/ada/a-coorse.adb +++ b/gcc/ada/a-coorse.adb @@ -288,13 +288,9 @@ package body Ada.Containers.Ordered_Sets is function Ceiling (Container : Set; Item : Element_Type) return Cursor is Node : constant Node_Access := Element_Keys.Ceiling (Container.Tree, Item); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Ceiling; ----------- @@ -385,7 +381,6 @@ package body Ada.Containers.Ordered_Sets is procedure Delete_First (Container : in out Set) is Tree : Tree_Type renames Container.Tree; X : Node_Access := Tree.First; - begin if X /= null then Tree_Operations.Delete_Node_Sans_Free (Tree, X); @@ -400,7 +395,6 @@ package body Ada.Containers.Ordered_Sets is procedure Delete_Last (Container : in out Set) is Tree : Tree_Type renames Container.Tree; X : Node_Access := Tree.Last; - begin if X /= null then Tree_Operations.Delete_Node_Sans_Free (Tree, X); @@ -446,13 +440,7 @@ package body Ada.Containers.Ordered_Sets is function Equivalent_Elements (Left, Right : Element_Type) return Boolean is begin - if Left < Right - or else Right < Left - then - return False; - else - return True; - end if; + return (if Left < Right or else Right < Left then False else True); end Equivalent_Elements; --------------------- @@ -472,13 +460,9 @@ package body Ada.Containers.Ordered_Sets is function Is_Equivalent_Node_Node (L, R : Node_Access) return Boolean is begin - if L.Element < R.Element then - return False; - elsif R.Element < L.Element then - return False; - else - return True; - end if; + return (if L.Element < R.Element then False + elsif R.Element < L.Element then False + else True); end Is_Equivalent_Node_Node; -- Start of processing for Equivalent_Sets @@ -508,13 +492,9 @@ package body Ada.Containers.Ordered_Sets is function Find (Container : Set; Item : Element_Type) return Cursor is Node : constant Node_Access := Element_Keys.Find (Container.Tree, Item); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Find; ----------- @@ -523,23 +503,16 @@ package body Ada.Containers.Ordered_Sets is function First (Container : Set) return Cursor is begin - if Container.Tree.First = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Container.Tree.First); + return + (if Container.Tree.First = null then No_Element + else Cursor'(Container'Unrestricted_Access, Container.Tree.First)); end First; function First (Object : Iterator) return Cursor is begin - if Object.Container = null then - return No_Element; - else - return - Cursor'( - Object.Container.all'Unrestricted_Access, - Object.Container.Tree.First); - end if; + return (if Object.Container = null then No_Element + else Cursor'(Object.Container.all'Unrestricted_Access, + Object.Container.Tree.First)); end First; ------------------- @@ -562,13 +535,9 @@ package body Ada.Containers.Ordered_Sets is function Floor (Container : Set; Item : Element_Type) return Cursor is Node : constant Node_Access := Element_Keys.Floor (Container.Tree, Item); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Floor; ---------- @@ -578,13 +547,11 @@ package body Ada.Containers.Ordered_Sets is procedure Free (X : in out Node_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Node_Type, Node_Access); - begin if X /= null then X.Parent := X; - X.Left := X; - X.Right := X; - + X.Left := X; + X.Right := X; Deallocate (X); end if; end Free; @@ -627,13 +594,9 @@ package body Ada.Containers.Ordered_Sets is function Ceiling (Container : Set; Key : Key_Type) return Cursor is Node : constant Node_Access := Key_Keys.Ceiling (Container.Tree, Key); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Ceiling; -------------- @@ -683,13 +646,7 @@ package body Ada.Containers.Ordered_Sets is function Equivalent_Keys (Left, Right : Key_Type) return Boolean is begin - if Left < Right - or else Right < Left - then - return False; - else - return True; - end if; + return (if Left < Right or else Right < Left then False else True); end Equivalent_Keys; ------------- @@ -698,7 +655,6 @@ package body Ada.Containers.Ordered_Sets is procedure Exclude (Container : in out Set; Key : Key_Type) is X : Node_Access := Key_Keys.Find (Container.Tree, Key); - begin if X /= null then Delete_Node_Sans_Free (Container.Tree, X); @@ -712,13 +668,9 @@ package body Ada.Containers.Ordered_Sets is function Find (Container : Set; Key : Key_Type) return Cursor is Node : constant Node_Access := Key_Keys.Find (Container.Tree, Key); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Find; ----------- @@ -727,13 +679,9 @@ package body Ada.Containers.Ordered_Sets is function Floor (Container : Set; Key : Key_Type) return Cursor is Node : constant Node_Access := Key_Keys.Floor (Container.Tree, Key); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Container'Unrestricted_Access, Node); + return (if Node = null then No_Element + else Cursor'(Container'Unrestricted_Access, Node)); end Floor; ------------------------- @@ -1214,22 +1162,16 @@ package body Ada.Containers.Ordered_Sets is function Last (Container : Set) return Cursor is begin - if Container.Tree.Last = null then - return No_Element; - else - return Cursor'(Container'Unrestricted_Access, Container.Tree.Last); - end if; + return + (if Container.Tree.Last = null then No_Element + else Cursor'(Container'Unrestricted_Access, Container.Tree.Last)); end Last; function Last (Object : Iterator) return Cursor is begin - if Object.Container = null then - return No_Element; - else - return Cursor'( - Object.Container.all'Unrestricted_Access, - Object.Container.Tree.Last); - end if; + return (if Object.Container = null then No_Element + else Cursor'(Object.Container.all'Unrestricted_Access, + Object.Container.Tree.Last)); end Last; ------------------ @@ -1267,8 +1209,7 @@ package body Ada.Containers.Ordered_Sets is -- Move -- ---------- - procedure Move is - new Tree_Operations.Generic_Move (Clear); + procedure Move is new Tree_Operations.Generic_Move (Clear); procedure Move (Target : in out Set; Source : in out Set) is begin @@ -1291,13 +1232,9 @@ package body Ada.Containers.Ordered_Sets is declare Node : constant Node_Access := Tree_Operations.Next (Position.Node); - begin - if Node = null then - return No_Element; - end if; - - return Cursor'(Position.Container, Node); + return (if Node = null then No_Element + else Cursor'(Position.Container, Node)); end; end Next; @@ -1347,11 +1284,8 @@ package body Ada.Containers.Ordered_Sets is Node : constant Node_Access := Tree_Operations.Previous (Position.Node); begin - if Node = null then - return No_Element; - else - return Cursor'(Position.Container, Node); - end if; + return (if Node = null then No_Element + else Cursor'(Position.Container, Node)); end; end Previous; @@ -1429,11 +1363,9 @@ package body Ada.Containers.Ordered_Sets is (Stream : not null access Root_Stream_Type'Class) return Node_Access is Node : Node_Access := new Node_Type; - begin Element_Type'Read (Stream, Node.Element); return Node; - exception when others => Free (Node); @@ -1532,11 +1464,10 @@ package body Ada.Containers.Ordered_Sets is function New_Node return Node_Access is begin Node.Element := Item; - Node.Color := Red; - Node.Parent := null; - Node.Right := null; - Node.Left := null; - + Node.Color := Red; + Node.Parent := null; + Node.Right := null; + Node.Left := null; return Node; end New_Node; @@ -1547,9 +1478,7 @@ package body Ada.Containers.Ordered_Sets is -- Start of processing for Replace_Element begin - if Item < Node.Element - or else Node.Element < Item - then + if Item < Node.Element or else Node.Element < Item then null; else |