diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-03-02 20:16:14 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-03-02 20:16:14 +0100 |
commit | da3d46cba8a16bd0981967ea7ed82d54042879ce (patch) | |
tree | f57aa687d2dd5488df0e71d98672b1e7b3265350 /libgomp/testsuite | |
parent | 268bc320088146b2eb3533ec6088e0b566e310de (diff) | |
download | gcc-da3d46cba8a16bd0981967ea7ed82d54042879ce.zip gcc-da3d46cba8a16bd0981967ea7ed82d54042879ce.tar.gz gcc-da3d46cba8a16bd0981967ea7ed82d54042879ce.tar.bz2 |
re PR libgomp/69555 (libgomp.c++/target-6.C fails because of undefined behaviour)
PR libgomp/69555
* gimplify.c (gimplify_decl_expr): For decls with REFERENCE_TYPE, also
gimplify_type_sizes the type they refer to.
(omp_notice_variable): Handle reference vars to VLAs.
* omp-low.c (lower_omp_target): Emit setup of OMP_CLAUSE_PRIVATE reference
to VLA decls in the second pass instead of first pass.
* testsuite/libgomp.c++/pr69555-1.C: New test.
* testsuite/libgomp.c++/pr69555-2.C: New test.
From-SVN: r233913
Diffstat (limited to 'libgomp/testsuite')
-rw-r--r-- | libgomp/testsuite/libgomp.c++/pr69555-1.C | 114 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c++/pr69555-2.C | 58 |
2 files changed, 172 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c++/pr69555-1.C b/libgomp/testsuite/libgomp.c++/pr69555-1.C new file mode 100644 index 0000000..c6885ff --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr69555-1.C @@ -0,0 +1,114 @@ +// PR libgomp/69555 +// { dg-do run } + +#include <omp.h> + +__attribute__((noinline, noclone)) void +f1 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + c[0] = 111; + int e = 0; + + #pragma omp parallel private (c) num_threads (4) reduction (+:e) + { + int v = omp_get_thread_num (); + for (int i = 0; i < y - 2; i++) + c[i] = i + v; + #pragma omp barrier + for (int i = 0; i < y - 2; i++) + if (c[i] != i + v) + e++; + } + if (c[0] != 111 || e) + __builtin_abort (); +} + +__attribute__((noinline, noclone)) void +f2 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + c[0] = 111; + + #pragma omp task private (c) + { + int v = omp_get_thread_num (); + for (int i = 0; i < y - 2; i++) + c[i] = i + v; + asm volatile ("" : : "r" (&c[0]) : "memory"); + for (int i = 0; i < y - 2; i++) + if (c[i] != i + v) + __builtin_abort (); + } + if (c[0] != 111) + __builtin_abort (); +} + +__attribute__((noinline, noclone)) void +f3 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + for (int i = 0; i < y - 2; i++) + c[i] = i + 4; + + #pragma omp parallel firstprivate (c) num_threads (4) + { + int v = omp_get_thread_num (); + for (int i = 0; i < y - 2; i++) + { + if (c[i] != i + 4) + __builtin_abort (); + c[i] = i + v; + } + #pragma omp barrier + for (int i = 0; i < y - 2; i++) + if (c[i] != i + v) + __builtin_abort (); + } + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 4) + __builtin_abort (); +} + +__attribute__((noinline, noclone)) void +f4 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + for (int i = 0; i < y - 2; i++) + c[i] = i + 4; + + #pragma omp task firstprivate (c) + { + int v = omp_get_thread_num (); + for (int i = 0; i < y - 2; i++) + { + if (c[i] != i + 4) + __builtin_abort (); + c[i] = i + v; + } + asm volatile ("" : : "r" (&c[0]) : "memory"); + for (int i = 0; i < y - 2; i++) + if (c[i] != i + v) + __builtin_abort (); + } + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 4) + __builtin_abort (); +} + +int +main () +{ + f1 (6); + f3 (6); + #pragma omp parallel num_threads (4) + { + f2 (6); + f4 (6); + } + return 0; +} diff --git a/libgomp/testsuite/libgomp.c++/pr69555-2.C b/libgomp/testsuite/libgomp.c++/pr69555-2.C new file mode 100644 index 0000000..78776ea --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr69555-2.C @@ -0,0 +1,58 @@ +// PR libgomp/69555 +// { dg-do run } + +__attribute__((noinline, noclone)) void +f1 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + for (int i = 0; i < y - 2; i++) + c[i] = i + 4; + + #pragma omp target firstprivate (c) + { + for (int i = 0; i < y - 2; i++) + { + if (c[i] != i + 4) + __builtin_abort (); + c[i] = i + 9; + } + asm volatile ("" : : "r" (&c[0]) : "memory"); + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 9) + __builtin_abort (); + } + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 4) + __builtin_abort (); +} + +__attribute__((noinline, noclone)) void +f2 (int y) +{ + int a[y - 2]; + int (&c)[y - 2] = a; + for (int i = 0; i < y - 2; i++) + c[i] = i + 4; + + #pragma omp target private (c) + { + for (int i = 0; i < y - 2; i++) + c[i] = i + 9; + asm volatile ("" : : "r" (&c[0]) : "memory"); + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 9) + __builtin_abort (); + } + for (int i = 0; i < y - 2; i++) + if (c[i] != i + 4) + __builtin_abort (); +} + +int +main () +{ + f1 (6); + f2 (6); + return 0; +} |