From 906c376300b029f2b5e23dcca65f49dfc47c3908 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 15 Feb 2019 08:51:38 +0100 Subject: [PATCH] opts-1.c: New test. * 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 | 7 ++++++ gcc/testsuite/c-c++-common/ubsan/opts-1.c | 23 +++++++++++++++++++ gcc/testsuite/c-c++-common/ubsan/opts-2.c | 23 +++++++++++++++++++ gcc/testsuite/c-c++-common/ubsan/opts-3.c | 23 +++++++++++++++++++ gcc/testsuite/c-c++-common/ubsan/opts-4.c | 27 +++++++++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/ubsan/opts-1.c create mode 100644 gcc/testsuite/c-c++-common/ubsan/opts-2.c create mode 100644 gcc/testsuite/c-c++-common/ubsan/opts-3.c create mode 100644 gcc/testsuite/c-c++-common/ubsan/opts-4.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b5b422f668..1223b68adf5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-02-15 Jakub Jelinek + + * 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 Jakub Jelinek 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 index 00000000000..0483b09cc41 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/opts-1.c @@ -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 index 00000000000..89f5e4cf68e --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/opts-2.c @@ -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 index 00000000000..7ec51478c5a --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/opts-3.c @@ -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 index 00000000000..dfe3e6b7a70 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/opts-4.c @@ -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; +} -- 2.30.2