diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-02-15 08:51:38 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-02-15 08:51:38 +0100 |
commit | 906c376300b029f2b5e23dcca65f49dfc47c3908 (patch) | |
tree | 19b78d6de2db4609d763ff88eac5a22582bdf6e0 | |
parent | 4c9ed22ae08c2b621efd6c8a1600e47b67d66c66 (diff) | |
download | gcc-906c376300b029f2b5e23dcca65f49dfc47c3908.zip gcc-906c376300b029f2b5e23dcca65f49dfc47c3908.tar.gz gcc-906c376300b029f2b5e23dcca65f49dfc47c3908.tar.bz2 |
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
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/opts-1.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/opts-2.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/opts-3.c | 23 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/opts-4.c | 27 |
5 files changed, 103 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6b5b422..1223b68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..0483b09 --- /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 0000000..89f5e4c --- /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 0000000..7ec5147 --- /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 0000000..dfe3e6b --- /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; +} |