+2019-09-18 Bob Duff <duff@adacore.com>
+
+ * libgnat/a-cbhama.adb, libgnat/a-cbhase.adb,
+ libgnat/a-cbmutr.adb, libgnat/a-cborma.adb,
+ libgnat/a-cborse.adb, libgnat/a-cobove.adb (Copy): Avoid reading
+ the uninitialized variable C in the Checks = False case. Change
+ variable to be a constant.
+
2019-09-18 Claire Dross <dross@adacore.com>
* libgnat/a-cofuma.adb (Remove, Elements_Equal_Except,
Capacity : Count_Type := 0;
Modulus : Hash_Type := 0) return Map
is
- C : Count_Type;
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Length
+ else Capacity);
M : Hash_Type;
begin
- if Capacity = 0 then
- C := Source.Length;
-
- elsif Capacity >= Source.Length then
- C := Capacity;
-
- elsif Checks then
- raise Capacity_Error with "Capacity value too small";
+ if Checks and then C < Source.Length then
+ raise Capacity_Error with "Capacity too small";
end if;
if Modulus = 0 then
Capacity : Count_Type := 0;
Modulus : Hash_Type := 0) return Set
is
- C : Count_Type;
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Length
+ else Capacity);
M : Hash_Type;
begin
- if Capacity = 0 then
- C := Source.Length;
- elsif Capacity >= Source.Length then
- C := Capacity;
- elsif Checks then
- raise Capacity_Error with "Capacity value too small";
+ if Checks and then C < Source.Length then
+ raise Capacity_Error with "Capacity too small";
end if;
if Modulus = 0 then
(Source : Tree;
Capacity : Count_Type := 0) return Tree
is
- C : Count_Type;
-
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Count
+ else Capacity);
begin
- if Capacity = 0 then
- C := Source.Count;
- elsif Capacity >= Source.Count then
- C := Capacity;
- elsif Checks then
- raise Capacity_Error with "Capacity value too small";
+ if Checks and then C < Source.Count then
+ raise Capacity_Error with "Capacity too small";
end if;
return Target : Tree (Capacity => C) do
----------
function Copy (Source : Map; Capacity : Count_Type := 0) return Map is
- C : Count_Type;
-
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Length
+ else Capacity);
begin
- if Capacity = 0 then
- C := Source.Length;
-
- elsif Capacity >= Source.Length then
- C := Capacity;
-
- elsif Checks then
- raise Capacity_Error with "Capacity value too small";
+ if Checks and then C < Source.Length then
+ raise Capacity_Error with "Capacity too small";
end if;
return Target : Map (Capacity => C) do
----------
function Copy (Source : Set; Capacity : Count_Type := 0) return Set is
- C : Count_Type;
-
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Length
+ else Capacity);
begin
- if Capacity = 0 then
- C := Source.Length;
- elsif Capacity >= Source.Length then
- C := Capacity;
- elsif Checks then
- raise Capacity_Error with "Capacity value too small";
+ if Checks and then C < Source.Length then
+ raise Capacity_Error with "Capacity too small";
end if;
return Target : Set (Capacity => C) do
(Source : Vector;
Capacity : Count_Type := 0) return Vector
is
- C : Count_Type;
-
+ C : constant Count_Type :=
+ (if Capacity = 0 then Source.Length
+ else Capacity);
begin
- if Capacity = 0 then
- C := Source.Length;
-
- elsif Capacity >= Source.Length then
- C := Capacity;
-
- elsif Checks then
- raise Capacity_Error
- with "Requested capacity is less than Source length";
+ if Checks and then C < Source.Length then
+ raise Capacity_Error with "Capacity too small";
end if;
return Target : Vector (C) do
+2019-09-18 Bob Duff <duff@adacore.com>
+
+ * gnat.dg/containers1.adb, gnat.dg/containers1.ads: New
+ testcase.
+
2019-09-18 Richard Sandiford <richard.sandiford@arm.com>
* gcc.target/i386/pr82361-1.c (f1, f2, f3, f4, f5, f6): Force
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-Wall -O2" }
+package body Containers1 is
+ procedure Dummy is null;
+end Containers1;
--- /dev/null
+with Ada.Containers.Bounded_Ordered_Sets; use Ada.Containers;
+package Containers1 is
+ pragma Suppress (All_Checks);
+ package Sets is new Bounded_Ordered_Sets (Boolean);
+ procedure Dummy;
+end Containers1;
\ No newline at end of file