diff options
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/div-by-zero-3.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-1.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-10.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-11.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-2.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-3.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-4.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-5.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-6.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-7.c | 18 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-8.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/null-9.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/shift-1.c | 12 |
13 files changed, 183 insertions, 9 deletions
diff --git a/gcc/testsuite/c-c++-common/ubsan/div-by-zero-3.c b/gcc/testsuite/c-c++-common/ubsan/div-by-zero-3.c index 719e6c98634..f3ee23bd021 100644 --- a/gcc/testsuite/c-c++-common/ubsan/div-by-zero-3.c +++ b/gcc/testsuite/c-c++-common/ubsan/div-by-zero-3.c @@ -16,6 +16,6 @@ main (void) return 0; } -/* { dg-output "division of -2147483648 by -1 cannot be represented in type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*division of -2147483648 by -1 cannot be represented in type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*division of -2147483648 by -1 cannot be represented in type int(\n|\r\n|\r)" } */ +/* { dg-output "division of -2147483648 by -1 cannot be represented in type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*division of -2147483648 by -1 cannot be represented in type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*division of -2147483648 by -1 cannot be represented in type 'int'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-1.c b/gcc/testsuite/c-c++-common/ubsan/null-1.c new file mode 100644 index 00000000000..887dfdcdb9f --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-1.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + int *p = 0; + return *p; +} + +/* { dg-output "load of null pointer of type 'int'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-10.c b/gcc/testsuite/c-c++-common/ubsan/null-10.c new file mode 100644 index 00000000000..267ab1f321c --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-10.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + short *p = 0, *u; + *(u + *p) = 23; + return 0; +} + +/* { dg-output "load of null pointer of type 'short int'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-11.c b/gcc/testsuite/c-c++-common/ubsan/null-11.c new file mode 100644 index 00000000000..83e65af7e86 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-11.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +struct S { + int i; +}; + +int +main (void) +{ + struct S **s = 0; + return (*s)->i; +} + +/* { dg-output "load of null pointer of type 'struct S \\*'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-2.c b/gcc/testsuite/c-c++-common/ubsan/null-2.c new file mode 100644 index 00000000000..c5303ea97a7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-2.c @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + int ***ppp = 0; + return ***ppp; +} + +/* { dg-output "load of null pointer of type 'int \\*\\*'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-3.c b/gcc/testsuite/c-c++-common/ubsan/null-3.c new file mode 100644 index 00000000000..0beb20cfbd0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-3.c @@ -0,0 +1,19 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +foo (int *p) +{ + return *p; +} + +int +main (void) +{ + int **p = 0; + return foo (*p); +} + +/* { dg-output "load of null pointer of type 'int \\*'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-4.c b/gcc/testsuite/c-c++-common/ubsan/null-4.c new file mode 100644 index 00000000000..b5f03ed0b60 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-4.c @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + _Complex double *p = 0; + if (p[0]) + return 42; + return 0; +} + +/* { dg-output "load of null pointer of type 'complex double'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-5.c b/gcc/testsuite/c-c++-common/ubsan/null-5.c new file mode 100644 index 00000000000..f6db4744446 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-5.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +typedef volatile const _Complex float *T; + +int +main (void) +{ + T t = 0; + if (*t) + return 42; + return 0; +} + +/* { dg-output "load of null pointer of type 'volatile const complex float'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-6.c b/gcc/testsuite/c-c++-common/ubsan/null-6.c new file mode 100644 index 00000000000..705635c0d84 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-6.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int +main (void) +{ + unsigned long int *p = 0; + *p = 42; + return 0; +} + +/* { dg-output "store to null pointer of type 'long unsigned int'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-7.c b/gcc/testsuite/c-c++-common/ubsan/null-7.c new file mode 100644 index 00000000000..1d8216a3d2f --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-7.c @@ -0,0 +1,18 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +int * +gao (void) +{ + return 0; +} + +int +main (void) +{ + return *gao (); +} + +/* { dg-output "load of null pointer of type 'int'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-8.c b/gcc/testsuite/c-c++-common/ubsan/null-8.c new file mode 100644 index 00000000000..2cf3939ca5e --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-8.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +struct S { + int i; +}; + +int +main (void) +{ + struct S *s = 0; + return s->i; +} + +/* { dg-output "member access within null pointer of type 'struct S'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/null-9.c b/gcc/testsuite/c-c++-common/ubsan/null-9.c new file mode 100644 index 00000000000..7fabbeca4c7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/null-9.c @@ -0,0 +1,17 @@ +/* { dg-do run } */ +/* { dg-options "-fsanitize=null -w" } */ +/* { dg-shouldfail "ubsan" } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ + +union U { + int i; +}; + +int +main (void) +{ + union U *u = 0; + return u->i; +} + +/* { dg-output "member access within null pointer of type 'union U'(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-1.c b/gcc/testsuite/c-c++-common/ubsan/shift-1.c index 48cf3cd7bff..0928ff7a102 100644 --- a/gcc/testsuite/c-c++-common/ubsan/shift-1.c +++ b/gcc/testsuite/c-c++-common/ubsan/shift-1.c @@ -23,9 +23,9 @@ main (void) return 0; } -/* { dg-output "shift exponent 152 is too large for \[^\n\r]*-bit type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*shift exponent 153 is too large for \[^\n\r]*-bit type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*shift exponent 154 is too large for \[^\n\r]*-bit type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*shift exponent 524 is too large for \[^\n\r]*-bit type long long unsigned int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*shift exponent 370 is too large for \[^\n\r]*-bit type int(\n|\r\n|\r)" } */ -/* { dg-output "\[^\n\r]*shift exponent 402 is too large for \[^\n\r]*-bit type long int(\n|\r\n|\r)" } */ +/* { dg-output "shift exponent 152 is too large for \[^\n\r]*-bit type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 153 is too large for \[^\n\r]*-bit type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 154 is too large for \[^\n\r]*-bit type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 524 is too large for \[^\n\r]*-bit type 'long long unsigned int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 370 is too large for \[^\n\r]*-bit type 'int'(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*shift exponent 402 is too large for \[^\n\r]*-bit type 'long int'(\n|\r\n|\r)" } */ |