diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3a20e92612c..e7e0a3c785b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,15 @@ +2014-09-18 Jakub Jelinek + + PR c++/63248 + * semantics.c (finish_omp_clauses): Don't call cp_omp_mappable_type + on type of type dependent expressions, and don't call it if + handle_omp_array_sections has kept TREE_LIST because something + was type dependent. + * pt.c (tsubst_expr) : + Use keep_next_level, begin_omp_structured_block and + finish_omp_structured_block instead of push_stmt_list and + pop_stmt_list. + 2014-09-18 Paolo Carlini PR c++/62232 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index b3a9c95ac60..8a12713471b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14089,8 +14089,6 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, case OMP_SECTIONS: case OMP_SINGLE: case OMP_TEAMS: - case OMP_TARGET_DATA: - case OMP_TARGET: tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, args, complain, in_decl); stmt = push_stmt_list (); @@ -14103,6 +14101,22 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, add_stmt (t); break; + case OMP_TARGET_DATA: + case OMP_TARGET: + tmp = tsubst_omp_clauses (OMP_CLAUSES (t), false, + args, complain, in_decl); + keep_next_level (true); + stmt = begin_omp_structured_block (); + + RECUR (OMP_BODY (t)); + stmt = finish_omp_structured_block (stmt); + + t = copy_node (t); + OMP_BODY (t) = stmt; + OMP_CLAUSES (t) = tmp; + add_stmt (t); + break; + case OMP_TARGET_UPDATE: tmp = tsubst_omp_clauses (OMP_TARGET_UPDATE_CLAUSES (t), false, args, complain, in_decl); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index aee92ddc1d0..bcf161bd921 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5668,7 +5668,9 @@ finish_omp_clauses (tree clauses) else { t = OMP_CLAUSE_DECL (c); - if (!cp_omp_mappable_type (TREE_TYPE (t))) + if (TREE_CODE (t) != TREE_LIST + && !type_dependent_expression_p (t) + && !cp_omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "array section does not have mappable type " @@ -5708,6 +5710,7 @@ finish_omp_clauses (tree clauses) remove = true; else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER) + && !type_dependent_expression_p (t) && !cp_omp_mappable_type ((TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE) ? TREE_TYPE (TREE_TYPE (t)) diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index ee73689e702..72caab9ac8b 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2014-09-18 Jakub Jelinek + + PR c++/63248 + * testsuite/libgomp.c++/pr63248.C: New test. + 2014-08-04 Jakub Jelinek * task.c (GOMP_taskgroup_end): If taskgroup->num_children diff --git a/libgomp/testsuite/libgomp.c++/pr63248.C b/libgomp/testsuite/libgomp.c++/pr63248.C new file mode 100644 index 00000000000..48d3f0af797 --- /dev/null +++ b/libgomp/testsuite/libgomp.c++/pr63248.C @@ -0,0 +1,62 @@ +// PR c++/63248 +// { dg-do run } + +int *v; + +template +T +foo (T A, T B) +{ + T a = 2; + T b = 4; + +#pragma omp target map(v[a:b]) + v[a] = 1; + +#pragma omp target map(v[A:B]) + v[a] = 2; + +#pragma omp target map(A) + A = 19; + return A; +} + +template +int +bar (int A, int B) +{ +#pragma omp target map(A) + A = 8; + if (A != 8) + __builtin_abort (); +#pragma omp target map(A, B) + { + A = 1; + B = 2; + } + return A + B; +} + +int +baz (int A, int B) +{ +#pragma omp target map(A) + A = 8; + if (A != 8) + __builtin_abort (); +#pragma omp target map(A, B) + { + A = 1; + B = 2; + } + return A + B; +} + +int +main () +{ + int a[10] = { 0 }; + v = a; + if (foo (1, 5) != 19 || v[2] != 2 || bar<0> (5, 7) != 3 || baz (5, 7) != 3) + __builtin_abort (); +}