[Ada] Different runtime behavior of Predicate_Failure
This patch corrects the generation of predicate checks to handle the case where Predicate_Failure appears as a pragma. ------------ -- Source -- ------------ -- main.adb with Ada.Assertions; use Ada.Assertions; with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; procedure Main is subtype Even_Asp is Integer with Predicate => Even_Asp mod 2 = 0, Predicate_Failure => "Even_Asp failed"; subtype Even_Prag is Integer with Predicate => Even_Prag mod 2 = 0; pragma Predicate_Failure (Even_Prag, "Even_Prag failed"); begin begin declare Val : constant Even_Asp := 1; begin Put_Line ("ERROR: Even_Asp: did not fail"); end; exception when AE : Assertion_Error => Put_Line (Exception_Message (AE)); when others => Put_Line ("ERROR: Even_Asp: raised unexpected error"); end; begin declare Val : constant Even_Prag := 3; begin Put_Line ("ERROR: Even_Prag: did not fail"); end; exception when AE : Assertion_Error => Put_Line (Exception_Message (AE)); when others => Put_Line ("ERROR: Even_Prag: raised unexpected error"); end; end Main; ---------------------------- -- Compilation and output -- ---------------------------- $ gnatmake -q main.adb $ ./main Even_Asp failed Even_Prag failed 2018-01-11 Hristian Kirtchev <kirtchev@adacore.com> gcc/ada/ * exp_util.adb (Add_Failure_Expression): New routine. (Make_Predicate_Check): Reimplement the handling of Predicate_Failure. * sem_util.adb (Is_Current_Instance): Code cleanup. From-SVN: r256493
Showing
Please
register
or
sign in
to comment