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
This commit is contained in:
parent
4c9ed22ae0
commit
906c376300
@ -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>
|
||||
|
||||
|
23
gcc/testsuite/c-c++-common/ubsan/opts-1.c
Normal file
23
gcc/testsuite/c-c++-common/ubsan/opts-1.c
Normal file
@ -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;
|
||||
}
|
23
gcc/testsuite/c-c++-common/ubsan/opts-2.c
Normal file
23
gcc/testsuite/c-c++-common/ubsan/opts-2.c
Normal file
@ -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;
|
||||
}
|
23
gcc/testsuite/c-c++-common/ubsan/opts-3.c
Normal file
23
gcc/testsuite/c-c++-common/ubsan/opts-3.c
Normal file
@ -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;
|
||||
}
|
27
gcc/testsuite/c-c++-common/ubsan/opts-4.c
Normal file
27
gcc/testsuite/c-c++-common/ubsan/opts-4.c
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user