Add test for PR97505.
authorAldy Hernandez <aldyh@redhat.com>
Mon, 2 Nov 2020 10:34:47 +0000 (11:34 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 2 Nov 2020 10:36:59 +0000 (11:36 +0100)
gcc/testsuite/ChangeLog:

PR tree-optimization/97505
* gcc.dg/pr97505.c: New test.

gcc/testsuite/gcc.dg/pr97505.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/pr97505.c b/gcc/testsuite/gcc.dg/pr97505.c
new file mode 100644 (file)
index 0000000..f01d912
--- /dev/null
@@ -0,0 +1,23 @@
+// { dg-do compile }
+// { dg-options "-Os -fsanitize=signed-integer-overflow -fdump-tree-evrp" }
+
+// Test that .UBSAN_CHECK_SUB(y, x) is treated as y-x for range
+// purposes, where X and Y are related to each other.
+//
+// This effectively checks that range relationals work with builtins.
+
+void unreachable();
+
+int foobar(int x, int y)
+{
+  if (x < y)
+    {
+      int z = y - x;
+      if (z == 0)
+        unreachable();
+      return z;
+    }
+  return 5;
+}
+
+// { dg-final { scan-tree-dump-not "unreachable" "evrp" } }