+2011-11-21 Ed Schonberg <schonberg@adacore.com>
+
+ * exp_ch6.adb (Expand_Actuals): In Ada 2012, a function call
+ with out parameters may generate assignments to force constraint
+ checks. These checks must be properly placed in the code after the
+ declaration or statement that contains the call.
+
+2011-11-21 Fedor Rybin <frybin@adacore.com>
+
+ * gnat_ugn.texi: Adding info on current gnattest limitations an
+ support of -X option.
+
+2011-11-21 Robert Dewar <dewar@adacore.com>
+
+ * a-cfdlli.adb, a-cbdlli.adb: Minor reformatting.
+
2011-11-20 Robert Dewar <dewar@adacore.com>
* exp_ch6.adb, exp_util.adb: Minor reformatting
"attempt to tamper with cursors of Source (list is busy)";
end if;
- Clear (Target); -- checks busy bit of Target
+ -- Clear target, note that this checks busy bits of Target
- while Source.Length > 1 loop
+ Clear (Target);
+ while Source.Length > 1 loop
pragma Assert (Source.First in 1 .. Source.Capacity);
pragma Assert (Source.Last /= Source.First);
pragma Assert (N (Source.First).Prev = 0);
-- in the unbounded form of the doubly-linked list container. In that
-- case, Free is an instantation of Unchecked_Deallocation, which can
-- fail (because PE will be raised if controlled Finalize fails), so
- -- we must defer the call until the very last step. Here in the
- -- bounded form, Free merely links the node we have just
- -- "deallocated" onto a list of inactive nodes, so technically Free
- -- cannot fail. However, for consistency, we handle Free the same way
- -- here as we do for the unbounded form, with the pessimistic
- -- assumption that it can fail.
+ -- we must defer the call until the last step. Here in the bounded
+ -- form, Free merely links the node we have just "deallocated" onto a
+ -- list of inactive nodes, so technically Free cannot fail. However,
+ -- for consistency, we handle Free the same way here as we do for the
+ -- unbounded form, with the pessimistic assumption that it can fail.
Free (Source, X);
end loop;
if Source.Length = 1 then
-
pragma Assert (Source.First in 1 .. Source.Capacity);
pragma Assert (Source.Last = Source.First);
pragma Assert (N (Source.First).Prev = 0);
declare
Nodes : Node_Array renames Position.Container.Nodes;
Node : constant Count_Type := Nodes (Position.Node).Next;
+
begin
if Node = 0 then
return No_Element;
begin
if Before.Node /= 0 then
- null;
pragma Assert (Vet (Container, Before), "bad cursor in Insert");
end if;
begin
if Before.Node /= 0 then
- null;
pragma Assert (Vet (Container, Before), "bad cursor in Insert");
end if;
Clear (Target);
while Source.Length > 1 loop
-
pragma Assert (Source.First in 1 .. Source.Capacity);
pragma Assert (Source.Last /= Source.First);
pragma Assert (N (Source.First).Prev = 0);
-- in the unbounded form of the doubly-linked list container. In that
-- case, Free is an instantation of Unchecked_Deallocation, which can
-- fail (because PE will be raised if controlled Finalize fails), so
- -- we must defer the call until the very last step. Here in the
- -- bounded form, Free merely links the node we have just
- -- "deallocated" onto a list of inactive nodes, so technically Free
- -- cannot fail. However, for consistency, we handle Free the same way
- -- here as we do for the unbounded form, with the pessimistic
- -- assumption that it can fail.
+ -- we must defer the call until the last step. Here in the bounded
+ -- form, Free merely links the node we have just "deallocated" onto a
+ -- list of inactive nodes, so technically Free cannot fail. However,
+ -- for consistency, we handle Free the same way here as we do for the
+ -- unbounded form, with the pessimistic assumption that it can fail.
Free (Source, X);
end loop;
if Source.Length = 1 then
-
pragma Assert (Source.First in 1 .. Source.Capacity);
pragma Assert (Source.Last = Source.First);
pragma Assert (N (Source.First).Prev = 0);
"attempt to tamper with cursors (list is locked)";
end if;
- pragma Assert (Vet (Container, Position),
- "bad cursor in Replace_Element");
+ pragma Assert
+ (Vet (Container, Position), "bad cursor in Replace_Element");
declare
N : Node_Array renames Container.Nodes;
begin
if Before.Node /= 0 then
- null;
pragma Assert (Vet (Target, Before), "bad cursor in Splice");
end if;
begin
if Before.Node /= 0 then
- null;
- pragma Assert (Vet (Container, Before),
- "bad Before cursor in Splice");
+ pragma Assert
+ (Vet (Container, Before), "bad Before cursor in Splice");
end if;
if Position.Node = 0 then
raise Constraint_Error with "Position cursor has no element";
end if;
- pragma Assert (Vet (Container, Position),
- "bad Position cursor in Splice");
+ pragma Assert
+ (Vet (Container, Position), "bad Position cursor in Splice");
if Position.Node = Before.Node
or else N (Position.Node).Next = Before.Node
raise Constraint_Error with "Position cursor has no element";
end if;
- pragma Assert (Vet (Container, Position),
- "bad cursor in Update_Element");
+ pragma Assert
+ (Vet (Container, Position), "bad cursor in Update_Element");
declare
B : Natural renames Container.Busy;
if not Is_Empty_List (Post_Call) then
- -- If call is not a list member, it must be the triggering statement
- -- of a triggering alternative or an entry call alternative, and we
- -- can add the post call stuff to the corresponding statement list.
+ -- Cases where the call is not a member of a statement list
if not Is_List_Member (N) then
declare
- P : constant Node_Id := Parent (N);
+ P : Node_Id := Parent (N);
begin
- pragma Assert (Nkind_In (P, N_Triggering_Alternative,
- N_Entry_Call_Alternative));
+ -- In Ada 2012 the call may be a function call in an expression
+ -- (since OUT and IN OUT parameters are now allowed for such
+ -- calls. The write-back of (in)-out parameters is handled
+ -- by the back-end, but the constraint checks generated when
+ -- subtypes of formal and actual don't match must be inserted
+ -- in the form of assignments, at the nearest point after the
+ -- declaration or statement that contains the call.
+
+ if Ada_Version >= Ada_2012
+ and then Nkind (N) = N_Function_Call
+ then
+ while Nkind (P) not in N_Declaration
+ and then
+ Nkind (P) not in N_Statement_Other_Than_Procedure_Call
+ loop
+ P := Parent (P);
+ end loop;
+
+ Insert_Actions_After (P, Post_Call);
+
+ -- If not the special Ada 2012 case of a function call, then
+ -- we must have the triggering statement of a triggering
+ -- alternative or an entry call alternative, and we can add
+ -- the post call stuff to the corresponding statement list.
- if Is_Non_Empty_List (Statements (P)) then
- Insert_List_Before_And_Analyze
- (First (Statements (P)), Post_Call);
else
- Set_Statements (P, Post_Call);
+ pragma Assert (Nkind_In (P, N_Triggering_Alternative,
+ N_Entry_Call_Alternative));
+
+ if Is_Non_Empty_List (Statements (P)) then
+ Insert_List_Before_And_Analyze
+ (First (Statements (P)), Post_Call);
+ else
+ Set_Statements (P, Post_Call);
+ end if;
end if;
+
end;
-- Otherwise, normal case where N is in a statement sequence,
Next_Formal (Formal);
end loop;
- -- If we are calling an Ada2012 function which needs to have the
+ -- If we are calling an Ada 2012 function which needs to have the
-- "accessibility level determined by the point of call" (AI05-0234)
-- passed in to it, then pass it in.
return False;
-- Handle a corner case, a cross-dialect subp renaming. For example,
- -- an Ada2012 renaming of an Ada05 subprogram. This can occur when a
- -- non-Ada2012 unit references predefined runtime units.
+ -- an Ada 2012 renaming of an Ada 05 subprogram. This can occur when a
+ -- non-Ada 2012 unit references predefined run-time units.
elsif Present (Alias (Func_Id)) then
test_runner
@end smallexample
+Note that you might need to specify the necessary values of scenario variables
+when you are not using the AUnit defaults.
+
@item actual unit test stubs
a test stub for each visible subprogram is created in a separate file, if it
doesn't exist already. By default, those separate test files are located in a
the corresponding unit test will be found in file
src/tests/my_unit-tests-proc_<code>.adb. <code> is a signature encoding used to
differentiate test names in cases of overloading.
+
+Note that if the project already has both my_unit.ads and my_unit-tests.ads this
+will cause name a conflict with generated test package.
@end itemize
@node Switches for gnattest
@cindex @option{-r} (@command{gnattest})
Recursively consider all sources from all projects.
+@item -X@var{name=value}
+@cindex @option{-X} (@command{gnattest})
+Indicate that external variable @var{name} has the value @var{value}.
+
@item -q
@cindex @option{-q} (@command{gnattest})
Suppresses noncritical output messages.
@item generic tests for generic packages and package instantiations
@item tests for protected subprograms and entries
@item aspects Precondition, Postcondition, and Test_Case
+@item generating test packages for code that is not conformant with ada 2005
+
@end itemize
@c *********************************