Add testcase for incorrect optimization in Ada
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 31 Jan 2022 08:14:41 +0000 (09:14 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Mon, 31 Jan 2022 08:15:30 +0000 (09:15 +0100)
gcc/testsuite/
* gnat.dg/div_zero.adb: New test.

gcc/testsuite/gnat.dg/div_zero.adb [new file with mode: 0644]

diff --git a/gcc/testsuite/gnat.dg/div_zero.adb b/gcc/testsuite/gnat.dg/div_zero.adb
new file mode 100644 (file)
index 0000000..c7237bd
--- /dev/null
@@ -0,0 +1,23 @@
+-- { dg-do run }
+
+-- This test requires architecture- and OS-specific support code for unwinding
+-- through signal frames (typically located in *-unwind.h) to pass.  Feel free
+-- to disable it if this code hasn't been implemented yet.
+
+procedure Div_Zero is
+
+  pragma Suppress (All_Checks);
+
+  function Zero return Integer is
+  begin
+    return 0;
+  end;
+
+  D : Integer := Zero;
+
+begin
+  D := 1 / D;
+  raise Program_Error;
+exception
+  when Constraint_Error => null;
+end;