diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-08-22 10:27:46 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-08-22 10:27:46 +0000 |
commit | f733cf303bcdc952c92b81dd62199a40a1f555ec (patch) | |
tree | 0a9a9e0f28aa7c7f5bc4d1d1d0e9647163cac4f7 /gcc/testsuite/c-c++-common | |
parent | e0e4357b88efe5dc53e50d341a09de4d02331200 (diff) | |
download | gcc-tarball-gcc-6.2.0.tar.gz |
gcc-6.2.0gcc-6.2.0
Diffstat (limited to 'gcc/testsuite/c-c++-common')
-rw-r--r-- | gcc/testsuite/c-c++-common/asan/pr70712.c | 32 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/cache-1.c | 66 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/cache-2.c | 57 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/combined-directives.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/combined-reduction.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/reduction-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/reduction-2.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/reduction-3.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/goacc/reduction-4.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/clauses-1.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/pr71371.c | 25 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/pr71758.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr69669.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr71372.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/bounds-13.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/pr71512-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/ubsan/pr71512-2.c | 5 |
17 files changed, 268 insertions, 56 deletions
diff --git a/gcc/testsuite/c-c++-common/asan/pr70712.c b/gcc/testsuite/c-c++-common/asan/pr70712.c new file mode 100644 index 0000000000..74a6a75f20 --- /dev/null +++ b/gcc/testsuite/c-c++-common/asan/pr70712.c @@ -0,0 +1,32 @@ +/* PR sanitizer/70712 */ +/* { dg-do run } */ + +struct __attribute__((aligned (64))) S +{ + char s[4]; +}; + +struct T +{ + char t[8]; + char u[480]; + +}; + +__attribute__((noinline, noclone)) void +foo (struct T *p, struct S *q) +{ + __builtin_memset (p->t, '\0', sizeof (p->t)); + __builtin_memset (p->u, '\0', sizeof (p->u)); + __builtin_memset (q->s, '\0', sizeof (q->s)); +} + +int +main () +{ + struct S s; + struct T t; + foo (&t, &s); + asm volatile ("" : : "r" (&t), "r" (&s) : "memory"); + return 0; +} diff --git a/gcc/testsuite/c-c++-common/goacc/cache-1.c b/gcc/testsuite/c-c++-common/goacc/cache-1.c index 950334102d..1d4759e738 100644 --- a/gcc/testsuite/c-c++-common/goacc/cache-1.c +++ b/gcc/testsuite/c-c++-common/goacc/cache-1.c @@ -1,3 +1,7 @@ +/* OpenACC cache directive: valid usage. */ +/* For execution testing, this file is "#include"d from + libgomp/testsuite/libgomp.oacc-c-c++-common/cache-1.c. */ + int main (int argc, char **argv) { @@ -21,57 +25,31 @@ main (int argc, char **argv) int n = 1; const int len = n; -#pragma acc cache /* { dg-error "expected '\\\(' before end of line" } */ - -#pragma acc cache a[0:N] /* { dg-error "expected '\\\(' before 'a'" } */ - /* { dg-bogus "expected end of line before 'a'" "" { xfail c++ } 26 } */ - -#pragma acc cache (a) /* { dg-error "expected '\\\['" } */ - -#pragma acc cache ( /* { dg-error "expected (identifier|unqualified-id) before end of line" } */ - -#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ - -#pragma acc cache (,) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" } */ - -#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ - -#pragma acc cache (a[0:N],) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" "" { xfail c } } */ - -#pragma acc cache (a[0:N]) copyin (a[0:N]) /* { dg-error "expected end of line before 'copyin'" } */ - -#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ - -#pragma acc cache (a[0:N] b[0:N]) /* { dg-error "expected '\\\)' before 'b'" } */ - -#pragma acc cache (a[0:N] b[0:N}) /* { dg-error "expected '\\\)' before 'b'" } */ - /* { dg-bogus "expected end of line before '\\\}' token" "" { xfail c++ } 47 } */ - -#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ - -#pragma acc cache (a[ii]) /* { dg-error "'ii' is not a constant" } */ - -#pragma acc cache (a[idx:n]) /* { dg-error "'n' is not a constant" } */ - -#pragma acc cache (a[0:N]) ( /* { dg-error "expected end of line before '\\(' token" } */ - -#pragma acc cache (a[0:N]) ii /* { dg-error "expected end of line before 'ii'" } */ - -#pragma acc cache (a[0:N] ii) /* { dg-error "expected '\\)' before 'ii'" } */ - + /* Have at it, GCC! */ #pragma acc cache (a[0:N]) - #pragma acc cache (a[0:N], a[0:N]) - #pragma acc cache (a[0:N], b[0:N]) - #pragma acc cache (a[0]) - #pragma acc cache (a[0], a[1], b[0:N]) - +#pragma acc cache (a[i - 5]) +#pragma acc cache (a[i + 5:len]) +#pragma acc cache (a[i + 5:len - 1]) +#pragma acc cache (b[i]) +#pragma acc cache (b[i:len]) +#pragma acc cache (a[ii]) +#pragma acc cache (a[ii:len]) +#pragma acc cache (b[ii - 1]) +#pragma acc cache (b[ii - 1:len]) +#pragma acc cache (b[i - ii + 1]) +#pragma acc cache (b[i + ii - 1:len]) +#pragma acc cache (b[i * ii - 1:len + 1]) +#pragma acc cache (a[idx + 2]) +#pragma acc cache (a[idx:len + 2]) #pragma acc cache (a[idx]) - #pragma acc cache (a[idx:len]) +#pragma acc cache (a[idx + 2:len]) +#pragma acc cache (a[idx + 2 + i:len]) +#pragma acc cache (a[idx + 2 + i + ii:len]) b[ii] = a[ii]; } diff --git a/gcc/testsuite/c-c++-common/goacc/cache-2.c b/gcc/testsuite/c-c++-common/goacc/cache-2.c new file mode 100644 index 0000000000..f717515791 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/cache-2.c @@ -0,0 +1,57 @@ +/* OpenACC cache directive: invalid usage. */ + +int +main (int argc, char **argv) +{ +#define N 2 + int a[N], b[N]; + int i; + + for (i = 0; i < N; i++) + { + a[i] = 3; + b[i] = 0; + } + +#pragma acc parallel copyin (a[0:N]) copyout (b[0:N]) +{ + int ii; + + for (ii = 0; ii < N; ii++) + { + const int idx = ii; + int n = 1; + const int len = n; + +#pragma acc cache /* { dg-error "expected '\\\(' before end of line" } */ +#pragma acc cache a[0:N] /* { dg-error "expected '\\\(' before 'a'" } */ + /* { dg-bogus "expected end of line before 'a'" "" { xfail c++ } 27 } */ +#pragma acc cache (a) /* { dg-error "expected '\\\['" } */ +#pragma acc cache ( /* { dg-error "expected (identifier|unqualified-id) before end of line" } */ +#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ +#pragma acc cache (,) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" } */ +#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ +#pragma acc cache (a[0:N],) /* { dg-error "expected (identifier|unqualified-id) before '(,|\\\))' token" "" { xfail c } } */ +#pragma acc cache (a[0:N]) copyin (a[0:N]) /* { dg-error "expected end of line before 'copyin'" } */ +#pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) before '\\\)' token" } */ +#pragma acc cache (a[0:N] b[0:N]) /* { dg-error "expected '\\\)' before 'b'" } */ +#pragma acc cache (a[0:N] b[0:N}) /* { dg-error "expected '\\\)' before 'b'" } */ + /* { dg-bogus "expected end of line before '\\\}' token" "" { xfail c++ } 38 } */ +#pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } */ +#pragma acc cache (a[0:N]) ( /* { dg-error "expected end of line before '\\(' token" } */ +#pragma acc cache (a[0:N]) ii /* { dg-error "expected end of line before 'ii'" } */ +#pragma acc cache (a[0:N] ii) /* { dg-error "expected '\\)' before 'ii'" } */ + + b[ii] = a[ii]; + } +} + + + for (i = 0; i < N; i++) + { + if (a[i] != b[i]) + __builtin_abort (); + } + + return 0; +} diff --git a/gcc/testsuite/c-c++-common/goacc/combined-directives.c b/gcc/testsuite/c-c++-common/goacc/combined-directives.c index c2a3c57b48..3fa800d7bb 100644 --- a/gcc/testsuite/c-c++-common/goacc/combined-directives.c +++ b/gcc/testsuite/c-c++-common/goacc/combined-directives.c @@ -111,6 +111,7 @@ test () // { dg-final { scan-tree-dump-times "acc loop vector" 2 "gimple" } } // { dg-final { scan-tree-dump-times "acc loop seq" 2 "gimple" } } // { dg-final { scan-tree-dump-times "acc loop auto" 2 "gimple" } } -// { dg-final { scan-tree-dump-times "acc loop tile.2, 3" 2 "gimple" } } +// XFAILed: OpenACC tile clauses are discarded during gimplification. +// { dg-final { scan-tree-dump-times "acc loop tile.2, 3" 2 "gimple" { xfail *-*-* } } } // { dg-final { scan-tree-dump-times "acc loop independent private.i" 2 "gimple" } } // { dg-final { scan-tree-dump-times "private.z" 2 "gimple" } } diff --git a/gcc/testsuite/c-c++-common/goacc/combined-reduction.c b/gcc/testsuite/c-c++-common/goacc/combined-reduction.c new file mode 100644 index 0000000000..ecf23f59d6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/combined-reduction.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenacc -fdump-tree-gimple" } */ + +#include <assert.h> + +int +main () +{ + int i, v1 = 0, n = 100; + +#pragma acc parallel loop reduction(+:v1) + for (i = 0; i < n; i++) + v1++; + + assert (v1 == n); + +#pragma acc kernels loop reduction(+:v1) + for (i = 0; i < n; i++) + v1++; + + assert (v1 == n); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "omp target oacc_parallel reduction.+:v1. map.tofrom:v1" 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "acc loop reduction.+:v1. private.i." 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "omp target oacc_kernels map.force_tofrom:n .len: 4.. map.force_tofrom:v1 .len: 4.." 1 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "acc loop reduction.+:v1. private.i." 1 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-1.c b/gcc/testsuite/c-c++-common/goacc/reduction-1.c index 3c1c2dda6c..35bfc86870 100644 --- a/gcc/testsuite/c-c++-common/goacc/reduction-1.c +++ b/gcc/testsuite/c-c++-common/goacc/reduction-1.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ /* Integer reductions. */ #define n 1000 @@ -65,3 +66,7 @@ main(void) return 0; } + +/* Check that default copy maps are generated for loop reductions. */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 7 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-2.c b/gcc/testsuite/c-c++-common/goacc/reduction-2.c index c3105a2073..9dba035adb 100644 --- a/gcc/testsuite/c-c++-common/goacc/reduction-2.c +++ b/gcc/testsuite/c-c++-common/goacc/reduction-2.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ /* float reductions. */ #define n 1000 @@ -47,3 +48,7 @@ main(void) return 0; } + +/* Check that default copy maps are generated for loop reductions. */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 4 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-3.c b/gcc/testsuite/c-c++-common/goacc/reduction-3.c index 4dbde04bc3..669cd43811 100644 --- a/gcc/testsuite/c-c++-common/goacc/reduction-3.c +++ b/gcc/testsuite/c-c++-common/goacc/reduction-3.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ /* double reductions. */ #define n 1000 @@ -47,3 +48,7 @@ main(void) return 0; } + +/* Check that default copy maps are generated for loop reductions. */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 4 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/goacc/reduction-4.c b/gcc/testsuite/c-c++-common/goacc/reduction-4.c index c4572b97bb..5c3dfb1917 100644 --- a/gcc/testsuite/c-c++-common/goacc/reduction-4.c +++ b/gcc/testsuite/c-c++-common/goacc/reduction-4.c @@ -1,3 +1,4 @@ +/* { dg-additional-options "-fdump-tree-gimple" } */ /* complex reductions. */ #define n 1000 @@ -35,3 +36,7 @@ main(void) return 0; } + +/* Check that default copy maps are generated for loop reductions. */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:result \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(tofrom:lresult \\\[len: \[0-9\]+\\\]\\)" 2 "gimple" } } */ diff --git a/gcc/testsuite/c-c++-common/gomp/clauses-1.c b/gcc/testsuite/c-c++-common/gomp/clauses-1.c index 91aed3960f..fe90c2428e 100644 --- a/gcc/testsuite/c-c++-common/gomp/clauses-1.c +++ b/gcc/testsuite/c-c++-common/gomp/clauses-1.c @@ -34,7 +34,7 @@ foo (int d, int m, int i1, int i2, int p, int *idp, int s, void bar (int d, int m, int i1, int i2, int p, int *idp, int s, - int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q) + int nte, int tl, int nth, int g, int nta, int fi, int pp, int *q, int *dd) { #pragma omp for simd \ private (p) firstprivate (f) lastprivate (l) linear (ll:1) reduction(+:r) schedule(static, 4) collapse(1) nowait \ @@ -63,29 +63,30 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, } #pragma omp target parallel \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) + if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ + nowait depend(inout: dd[0]) ; #pragma omp target parallel for \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ - lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1) + lastprivate (l) linear (ll:1) ordered schedule(static, 4) collapse(1) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target parallel for simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ if (parallel: i2) default(shared) shared(s) reduction(+:r) num_threads (nth) proc_bind(spread) \ lastprivate (l) linear (ll:1) schedule(static, 4) collapse(1) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) + shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) nowait depend(inout: dd[0]) ; #pragma omp target teams distribute \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ - collapse(1) dist_schedule(static, 16) + collapse(1) dist_schedule(static, 16) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ; #pragma omp target teams distribute parallel for \ @@ -93,7 +94,7 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) \ if (parallel: i2) num_threads (nth) proc_bind(spread) \ - lastprivate (l) schedule(static, 4) + lastprivate (l) schedule(static, 4) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams distribute parallel for simd \ @@ -102,19 +103,20 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, collapse(1) dist_schedule(static, 16) \ if (parallel: i2) num_threads (nth) proc_bind(spread) \ lastprivate (l) schedule(static, 4) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target teams distribute simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) \ - safelen(8) simdlen(4) aligned(q: 32) + safelen(8) simdlen(4) aligned(q: 32) nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp target simd \ device(d) map (tofrom: m) if (target: i1) private (p) firstprivate (f) defaultmap(tofrom: scalar) is_device_ptr (idp) \ - safelen(8) simdlen(4) lastprivate (l) linear(ll: 1) aligned(q: 32) reduction(+:r) + safelen(8) simdlen(4) lastprivate (l) linear(ll: 1) aligned(q: 32) reduction(+:r) \ + nowait depend(inout: dd[0]) for (int i = 0; i < 64; i++) ll++; #pragma omp taskloop simd \ @@ -128,7 +130,7 @@ bar (int d, int m, int i1, int i2, int p, int *idp, int s, safelen(8) simdlen(4) linear(ll: 1) aligned(q: 32) reduction(+:r) for (int i = 0; i < 64; i++) ll++; - #pragma omp target + #pragma omp target nowait depend(inout: dd[0]) #pragma omp teams distribute \ private(p) firstprivate (f) shared(s) default(shared) reduction(+:r) num_teams(nte) thread_limit(tl) \ collapse(1) dist_schedule(static, 16) diff --git a/gcc/testsuite/c-c++-common/gomp/pr71371.c b/gcc/testsuite/c-c++-common/gomp/pr71371.c new file mode 100644 index 0000000000..da6e842b6e --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr71371.c @@ -0,0 +1,25 @@ +/* PR middle-end/71371 */ +/* { dg-do compile } */ + +void baz (int *); + +void +foo (void) +{ + int i; + #pragma omp taskloop + for (i = 0; i < 100; i++) + baz (&i); +} + +void +bar (void) +{ + int i; + #pragma omp parallel + { + #pragma omp for + for (i = 0; i < 100; i++) + baz (&i); + } +} diff --git a/gcc/testsuite/c-c++-common/gomp/pr71758.c b/gcc/testsuite/c-c++-common/gomp/pr71758.c new file mode 100644 index 0000000000..d3c86972ef --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr71758.c @@ -0,0 +1,10 @@ +/* PR middle-end/71758 */ + +void +foo (int *p) +{ + long long i = 0; + #pragma omp target device (i) + ; + #pragma omp target update device (i) to (p[0]) +} diff --git a/gcc/testsuite/c-c++-common/pr69669.c b/gcc/testsuite/c-c++-common/pr69669.c index 9940afe8ff..ebeb4109ff 100644 --- a/gcc/testsuite/c-c++-common/pr69669.c +++ b/gcc/testsuite/c-c++-common/pr69669.c @@ -1,5 +1,6 @@ /* PR c/69669 */ /* { dg-do compile } */ +/* { dg-options "-fdump-rtl-final" } */ enum __attribute__((mode(QI))) E { F = 1 }; @@ -8,3 +9,5 @@ foo (enum E *x, int y) { *x = (enum E) y; } + +/* { dg-final { scan-rtl-dump-times "mem:QI" 1 "final" } } */ diff --git a/gcc/testsuite/c-c++-common/pr71372.c b/gcc/testsuite/c-c++-common/pr71372.c new file mode 100644 index 0000000000..943adab628 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr71372.c @@ -0,0 +1,14 @@ +/* PR c++/71372 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +void +foo (volatile int *p, int q) +{ + *(volatile int *)p = 0; + *(p + (q - q) + 1) = 0; + *(p + (q - q) + 2) = 0; + *(p + (q - q) + 3) = 0; +} + +/* { dg-final { scan-tree-dump-times " ={v} " 4 "optimized" } } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/bounds-13.c b/gcc/testsuite/c-c++-common/ubsan/bounds-13.c new file mode 100644 index 0000000000..25b0467ec6 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/bounds-13.c @@ -0,0 +1,31 @@ +/* PR sanitizer/71498 */ +/* { dg-do run } */ +/* { dg-options "-fsanitize=bounds -Wno-array-bounds" } */ + +struct S { int a[100]; int b, c; } s; + +__attribute__((noinline, noclone)) int +foo (int x) +{ + return s.a[x]; +} + +__attribute__((noinline, noclone)) int +bar (int x) +{ + static int *d = &s.a[99]; + asm volatile ("" : : "r" (&d)); + return s.a[x]; +} + +int +main () +{ + volatile int a = 0; + a += foo (100); + a += bar (100); + return 0; +} + +/* { dg-output "index 100 out of bounds for type 'int \\\[100\\\]'\[^\n\r]*(\n|\r\n|\r)" } */ +/* { dg-output "\[^\n\r]*index 100 out of bounds for type 'int \\\[100\\\]'\[^\n\r]*(\n|\r\n|\r)" } */ diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c new file mode 100644 index 0000000000..2a90ab18d5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-1.c @@ -0,0 +1,5 @@ +/* PR c/71512 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fnon-call-exceptions -ftrapv -fexceptions -fsanitize=undefined" } */ + +#include "../../gcc.dg/pr44545.c" diff --git a/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c new file mode 100644 index 0000000000..1c955930be --- /dev/null +++ b/gcc/testsuite/c-c++-common/ubsan/pr71512-2.c @@ -0,0 +1,5 @@ +/* PR c/71512 */ +/* { dg-do compile } */ +/* { dg-options "-O -fexceptions -fnon-call-exceptions -ftrapv -fsanitize=undefined" } */ + +#include "../../gcc.dg/pr47086.c" |