aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/init.c
diff options
context:
space:
mode:
authorHristian Kirtchev <kirtchev@adacore.com>2018-01-11 08:51:39 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-01-11 08:51:39 +0000
commit806312986f95213e4321f4a282ff1738fe72c1ea (patch)
tree1d6b19fff5051188563921dccc1eb44ac05b1754 /gcc/ada/init.c
parent6a5e79b44f0d0d06c793ec200ef3b597b07ebc1a (diff)
downloadgcc-806312986f95213e4321f4a282ff1738fe72c1ea.zip
gcc-806312986f95213e4321f4a282ff1738fe72c1ea.tar.gz
gcc-806312986f95213e4321f4a282ff1738fe72c1ea.tar.bz2
[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
Diffstat (limited to 'gcc/ada/init.c')
0 files changed, 0 insertions, 0 deletions