+2014-10-10 Yannick Moy <moy@adacore.com>
+
+ * sem_prag.adb (Analyze_Global_Item): Accept formal objects in Global
+ contracts.
+ * errout.adb, errout.ads (SPARK_Msg_NE): Issue error unless
+ SPARK_Mode is Off.
+
+2014-10-10 Vadim Godunko <godunko@adacore.com>
+
+ * a-stwima.adb (To_Sequence): Compute size of result array.
+
+2014-10-10 Javier Miranda <miranda@adacore.com>
+
+ * gnat_ugn.texi (Interfacing with C++ at the Class Level): Update the
+ sources of the example to avoid a warning when the Ada files are
+ automatically generated by the binding generator.
+
+2014-10-10 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_attr.adb (Resolve_Attribute, case 'Update): Set
+ Do_Range_Check on the expression of a record component
+ association when needed, as is done for array components, when
+ the corresponding type is a scalar type.
+
2014-10-10 Gary Dismukes <dismukes@adacore.com>
* a-coinho-shared.adb: Minor typo fix.
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- --
-- 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- --
function To_Sequence
(Set : Wide_Character_Set) return Wide_Character_Sequence
is
- SS : constant Wide_Character_Ranges_Access := Set.Set;
-
- Result : Wide_String (Positive range 1 .. 2 ** 16);
- N : Natural := 0;
+ SS : constant Wide_Character_Ranges_Access := Set.Set;
+ N : Natural := 0;
+ Count : Natural := 0;
begin
for J in SS'Range loop
- for K in SS (J).Low .. SS (J).High loop
- N := N + 1;
- Result (N) := K;
- end loop;
+ Count :=
+ Count + (Wide_Character'Pos (SS (J).High) -
+ Wide_Character'Pos (SS (J).Low) + 1);
end loop;
- return Result (1 .. N);
+ return Result : Wide_String (1 .. Count) do
+ for J in SS'Range loop
+ for K in SS (J).Low .. SS (J).High loop
+ N := N + 1;
+ Result (N) := K;
+ end loop;
+ end loop;
+ end return;
end To_Sequence;
------------
side, and latter the reverse case.
The root of our derivation will be the @code{Animal} class, with a
-single private attribute (the @code{Age} of the animal) and two public
-primitives to set and get the value of this attribute.
+single private attribute (the @code{Age} of the animal), a constructor,
+and two public primitives to set and get the value of this attribute.
@smallexample
@b{class} Animal @{
@b{public}:
@b{virtual} void Set_Age (int New_Age);
@b{virtual} int Age ();
+ Animal() @{Age_Count = 0;@};
@b{private}:
int Age_Count;
@};
@smallexample @c ada
@b{with} Interfaces.C.Strings; @b{use} Interfaces.C.Strings;
@b{package} Animals @b{is}
- @b{type} Carnivore @b{is} interface;
+ @b{type} Carnivore @b{is} @b{limited} interface;
@b{pragma} Convention (C_Plus_Plus, Carnivore);
@b{function} Number_Of_Teeth (X : Carnivore)
@b{return} Natural @b{is} @b{abstract};
- @b{type} Domestic @b{is} interface;
- @b{pragma} Convention (C_Plus_Plus, Set_Owner);
+ @b{type} Domestic @b{is} @b{limited} interface;
+ @b{pragma} Convention (C_Plus_Plus, Domestic);
@b{procedure} Set_Owner
(X : @b{in} @b{out} Domestic;
Name : Chars_Ptr) @b{is} @b{abstract};
- @b{type} Animal @b{is} @b{tagged} @b{record}
- Age : Natural := 0;
+ @b{type} Animal @b{is} @b{tagged} @b{limited} @b{record}
+ Age : Natural;
@b{end} @b{record};
@b{pragma} Import (C_Plus_Plus, Animal);
@b{function} Age (X : Animal) @b{return} Integer;
@b{pragma} Import (C_Plus_Plus, Age);
+ @b{function} New_Animal @b{return} Animal;
+ @b{pragma} CPP_Constructor (New_Animal);
+ @b{pragma} Import (CPP, New_Animal, "_ZN6AnimalC1Ev");
+
@b{type} Dog @b{is} @b{new} Animal @b{and} Carnivore @b{and} Domestic @b{with} @b{record}
Tooth_Count : Natural;
Owner : String (1 .. 30);
@b{end} @b{record};
@b{pragma} Import (C_Plus_Plus, Dog);
- @b{function} Number_Of_Teeth (A : Dog) @b{return} Integer;
+ @b{function} Number_Of_Teeth (A : Dog) @b{return} Natural;
@b{pragma} Import (C_Plus_Plus, Number_Of_Teeth);
@b{procedure} Set_Owner (A : @b{in} @b{out} Dog; Name : Chars_Ptr);
@b{with} Interfaces.C.Strings;
@b{use} Interfaces.C.Strings;
@b{package} Animals @b{is}
- @b{type} Carnivore @b{is} interface;
+ @b{type} Carnivore @b{is} @b{limited} interface;
@b{pragma} Convention (C_Plus_Plus, Carnivore);
@b{function} Number_Of_Teeth (X : Carnivore)
@b{return} Natural @b{is} @b{abstract};
- @b{type} Domestic @b{is} interface;
- @b{pragma} Convention (C_Plus_Plus, Set_Owner);
+ @b{type} Domestic @b{is} @b{limited} interface;
+ @b{pragma} Convention (C_Plus_Plus, Domestic);
@b{procedure} Set_Owner
(X : @b{in} @b{out} Domestic;
Name : Chars_Ptr) @b{is} @b{abstract};
@b{type} Animal @b{is} @b{tagged} @b{record}
- Age : Natural := 0;
+ Age : Natural;
@b{end} @b{record};
@b{pragma} Convention (C_Plus_Plus, Animal);
@b{function} Age (X : Animal) @b{return} Integer;
@b{pragma} Export (C_Plus_Plus, Age);
+ @b{function} New_Animal @b{return} Animal'Class;
+ @b{pragma} Export (C_Plus_Plus, New_Animal);
+
@b{type} Dog @b{is} @b{new} Animal @b{and} Carnivore @b{and} Domestic @b{with} @b{record}
Tooth_Count : Natural;
Owner : String (1 .. 30);
@b{end} @b{record};
@b{pragma} Convention (C_Plus_Plus, Dog);
- @b{function} Number_Of_Teeth (A : Dog) @b{return} Integer;
+ @b{function} Number_Of_Teeth (A : Dog) @b{return} Natural;
@b{pragma} Export (C_Plus_Plus, Number_Of_Teeth);
@b{procedure} Set_Owner (A : @b{in} @b{out} Dog; Name : Chars_Ptr);
@b{end} Animals;
@end smallexample
-Compared with our previous example the only difference is the use of
+Compared with our previous example the only differences are the use of
+@code{pragma Convention} (instead of @code{pragma Import}), and the use of
@code{pragma Export} to indicate to the GNAT compiler that the primitives will
be available to C++. Thanks to the ABI compatibility, on the C++ side there is
nothing else to be done; as explained above, the only requirement is that all