opts-1.c: New test.
authorJakub Jelinek <jakub@redhat.com>
Fri, 15 Feb 2019 07:51:38 +0000 (08:51 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 15 Feb 2019 07:51:38 +0000 (08:51 +0100)
* c-c++-common/ubsan/opts-1.c: New test.
* c-c++-common/ubsan/opts-2.c: New test.
* c-c++-common/ubsan/opts-3.c: New test.
* c-c++-common/ubsan/opts-4.c: New test.

From-SVN: r268929

gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/opts-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/ubsan/opts-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/ubsan/opts-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/ubsan/opts-4.c [new file with mode: 0644]

index 6b5b422f66825bcc507a76951a09221e5f24d38a..1223b68adf5018c3e2820fdacd625b38bcda5c47 100644 (file)
@@ -1,3 +1,10 @@
+2019-02-15  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-c++-common/ubsan/opts-1.c: New test.
+       * c-c++-common/ubsan/opts-2.c: New test.
+       * c-c++-common/ubsan/opts-3.c: New test.
+       * c-c++-common/ubsan/opts-4.c: New test.
+
 2019-02-15  Richard Biener  <rguenther@suse.de>
            Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/c-c++-common/ubsan/opts-1.c b/gcc/testsuite/c-c++-common/ubsan/opts-1.c
new file mode 100644 (file)
index 0000000..0483b09
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -fsanitize=shift -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_shift_out_of_bounds" 1 "optimized" } } */
+
+int
+foo (int x, int y)
+{
+  return x / y;
+}
+
+int
+bar (int x, int y)
+{
+  return x << y;
+}
+
+float
+baz (float x, float y)
+{
+  return x / y;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/opts-2.c b/gcc/testsuite/c-c++-common/ubsan/opts-2.c
new file mode 100644 (file)
index 0000000..89f5e4c
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -fno-sanitize=shift -fsanitize=float-divide-by-zero -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" "optimized" } } */
+
+int
+foo (int x, int y)
+{
+  return x / y;
+}
+
+int
+bar (int x, int y)
+{
+  return x << y;
+}
+
+float
+baz (float x, float y)
+{
+  return x / y;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/opts-3.c b/gcc/testsuite/c-c++-common/ubsan/opts-3.c
new file mode 100644 (file)
index 0000000..7ec5147
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -fno-sanitize=shift -fno-sanitize=float-divide-by-zero -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__ubsan_handle_shift_out_of_bounds" "optimized" } } */
+
+int
+foo (int x, int y)
+{
+  return x / y;
+}
+
+int
+bar (int x, int y)
+{
+  return x << y;
+}
+
+float
+baz (float x, float y)
+{
+  return x / y;
+}
diff --git a/gcc/testsuite/c-c++-common/ubsan/opts-4.c b/gcc/testsuite/c-c++-common/ubsan/opts-4.c
new file mode 100644 (file)
index 0000000..dfe3e6b
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=integer-divide-by-zero -fno-sanitize-recover=shift -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-flto -fno-fat-lto-objects" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_divrem_overflow_abort" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_shift_out_of_bounds_abort" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__ubsan_handle_type_mismatch_v1" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "__ubsan_handle_type_mismatch_v1_abort" "optimized" } } */
+
+int
+foo (int x, int y)
+{
+  return x / y;
+}
+
+int
+bar (int x, int y)
+{
+  return x << y;
+}
+
+enum E { E0, E1, E2, E3 };
+
+enum E
+baz (enum E *x)
+{
+  return *x;
+}