diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/c/c-parser.cc | 2 | ||||
-rw-r--r-- | gcc/cp/parser.cc | 2 | ||||
-rw-r--r-- | gcc/omp-low.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/scope-5.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/gomp/scope-6.c | 31 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gomp/attrs-1.C | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/gomp/attrs-2.C | 6 |
7 files changed, 54 insertions, 5 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 7cc4d93c..c9a8d14 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -20413,7 +20413,9 @@ c_parser_omp_single (location_t loc, c_parser *parser, bool *if_p) #define OMP_SCOPE_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static tree diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index b3a6c9a..2106642 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -43747,7 +43747,9 @@ cp_parser_omp_single (cp_parser *parser, cp_token *pragma_tok, bool *if_p) #define OMP_SCOPE_CLAUSE_MASK \ ( (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_PRIVATE) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_FIRSTPRIVATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_REDUCTION) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_ALLOCATE) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT)) static tree diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc index 16f5965..f976e3a 100644 --- a/gcc/omp-low.cc +++ b/gcc/omp-low.cc @@ -683,6 +683,7 @@ build_outer_var_ref (tree var, omp_context *ctx, else if ((gimple_code (ctx->stmt) == GIMPLE_OMP_FOR && gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_SIMD) || ctx->loop_p + || code == OMP_CLAUSE_ALLOCATE || (code == OMP_CLAUSE_PRIVATE && (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR || gimple_code (ctx->stmt) == GIMPLE_OMP_SECTIONS @@ -4849,7 +4850,7 @@ lower_private_allocate (tree var, tree new_var, tree &allocator, allocator = TREE_PURPOSE (allocator); } if (TREE_CODE (allocator) != INTEGER_CST) - allocator = build_outer_var_ref (allocator, ctx); + allocator = build_outer_var_ref (allocator, ctx, OMP_CLAUSE_ALLOCATE); allocator = fold_convert (pointer_sized_int_node, allocator); if (TREE_CODE (allocator) != INTEGER_CST) { diff --git a/gcc/testsuite/c-c++-common/gomp/scope-5.c b/gcc/testsuite/c-c++-common/gomp/scope-5.c new file mode 100644 index 0000000..6cd4a80 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/scope-5.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +void +foo () +{ + int f = 0; + #pragma omp scope firstprivate(f) /* { dg-error "firstprivate variable 'f' is private in outer context" } */ + f++; +} diff --git a/gcc/testsuite/c-c++-common/gomp/scope-6.c b/gcc/testsuite/c-c++-common/gomp/scope-6.c new file mode 100644 index 0000000..760dd71 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/scope-6.c @@ -0,0 +1,31 @@ +typedef enum omp_allocator_handle_t +#if __cplusplus >= 201103L +: __UINTPTR_TYPE__ +#endif +{ + omp_null_allocator = 0, + omp_default_mem_alloc = 1, + omp_large_cap_mem_alloc = 2, + omp_const_mem_alloc = 3, + omp_high_bw_mem_alloc = 4, + omp_low_lat_mem_alloc = 5, + omp_cgroup_mem_alloc = 6, + omp_pteam_mem_alloc = 7, + omp_thread_mem_alloc = 8, + __omp_allocator_handle_t_max__ = __UINTPTR_MAX__ +} omp_allocator_handle_t; + +int a = 0, b = 42, c = 0; + +void +foo (omp_allocator_handle_t h) +{ + #pragma omp scope private (a) private (b) reduction (+: c) allocate (allocator (h): a, b, c) + { + if (b != 42) + __builtin_abort (); + a = 36; + b = 15; + c++; + } +} diff --git a/gcc/testsuite/g++.dg/gomp/attrs-1.C b/gcc/testsuite/g++.dg/gomp/attrs-1.C index f64b078..3f366ae 100644 --- a/gcc/testsuite/g++.dg/gomp/attrs-1.C +++ b/gcc/testsuite/g++.dg/gomp/attrs-1.C @@ -593,9 +593,11 @@ bar (int d, int m, int i1, int i2, int i3, int p, int *idp, int hda, int s, [[omp::directive (cancellation point parallel)]]; } } - [[omp::directive (scope private (p) reduction(+:r) nowait)]] + [[omp::directive (scope private (p) firstprivate (f) reduction(+:r) nowait + allocate (omp_default_mem_alloc: r))]] ; - [[omp::directive (scope private (p) reduction(task, +:r))]] + [[omp::directive (scope private (p) firstprivate (f) reduction(task, +:r) + allocate (omp_default_mem_alloc: f))]] ; extern int t2; [[omp::directive (threadprivate (t2))]]; diff --git a/gcc/testsuite/g++.dg/gomp/attrs-2.C b/gcc/testsuite/g++.dg/gomp/attrs-2.C index cc91fa2..cb80415 100644 --- a/gcc/testsuite/g++.dg/gomp/attrs-2.C +++ b/gcc/testsuite/g++.dg/gomp/attrs-2.C @@ -593,9 +593,11 @@ bar (int d, int m, int i1, int i2, int i3, int p, int *idp, int hda, int s, [[omp::directive (cancellation point, parallel)]]; } } - [[omp::directive (scope, private (p), reduction(+:r), nowait)]] + [[omp::directive (scope, private (p), firstprivate (f), reduction(+:r), nowait, + allocate(omp_default_mem_alloc: r))]] ; - [[using omp:directive (scope, private (p), reduction(task, +:r))]] + [[using omp:directive (scope, private (p), firstprivate (f), reduction(task, +:r), + allocate (omp_default_mem_alloc: f))]] ; extern int t2; [[omp::directive (threadprivate (t2))]]; |