diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -16998,6 +16998,25 @@ continue; } + // target, target data + // OpenMP 5.0 [2.12.2, Restrictions, p. 161] + // A map-type in a map clause must be to, from, tofrom or alloc + if ((DKind == OMPD_target || DKind == OMPD_target_data || + DKind == OMPD_target_parallel || DKind == OMPD_target_parallel_for || + DKind == OMPD_target_parallel_for_simd || + DKind == OMPD_target_simd || DKind == OMPD_target_teams || + DKind == OMPD_target_teams_distribute || + DKind == OMPD_target_teams_distribute_parallel_for || + DKind == OMPD_target_teams_distribute_parallel_for_simd) && + !(MapType == OMPC_MAP_to || MapType == OMPC_MAP_from || + MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc)) { + SemaRef.Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive) + << (IsMapTypeImplicit ? 1 : 0) + << getOpenMPSimpleClauseTypeName(OMPC_map, MapType) + << getOpenMPDirectiveName(DKind); + continue; + } + // OpenMP 4.5 [2.15.5.1, Restrictions, p.3] // A list item cannot appear in both a map clause and a data-sharing // attribute clause on the same construct diff --git a/clang/test/OpenMP/target_data_messages.c b/clang/test/OpenMP/target_data_messages.c --- a/clang/test/OpenMP/target_data_messages.c +++ b/clang/test/OpenMP/target_data_messages.c @@ -35,5 +35,15 @@ { foo(); } +#pragma omp target data map(delete \ + : a) // expected-error {{map type 'delete' is not allowed for '#pragma omp target data'}} + { + foo(); + } +#pragma omp target data map(release \ + : a) // expected-error {{map type 'release' is not allowed for '#pragma omp target data'}} + { + foo(); + } return 0; } diff --git a/clang/test/OpenMP/target_map_messages.cpp b/clang/test/OpenMP/target_map_messages.cpp --- a/clang/test/OpenMP/target_map_messages.cpp +++ b/clang/test/OpenMP/target_map_messages.cpp @@ -731,6 +731,12 @@ {} #pragma omp target map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}} {} +#pragma omp target map(delete \ + : a) // expected-error {{map type 'delete' is not allowed for '#pragma omp target'}} + {} +#pragma omp target map(release \ + : a) // expected-error {{map type 'release' is not allowed for '#pragma omp target'}} + {} return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_parallel_for_map_messages.cpp b/clang/test/OpenMP/target_parallel_for_map_messages.cpp --- a/clang/test/OpenMP/target_parallel_for_map_messages.cpp +++ b/clang/test/OpenMP/target_parallel_for_map_messages.cpp @@ -288,6 +288,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target parallel for map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel for'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target parallel for map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel for'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp b/clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp --- a/clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp +++ b/clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp @@ -288,6 +288,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target parallel for simd map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel for simd'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target parallel for simd map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel for simd'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_parallel_map_messages.cpp b/clang/test/OpenMP/target_parallel_map_messages.cpp --- a/clang/test/OpenMP/target_parallel_map_messages.cpp +++ b/clang/test/OpenMP/target_parallel_map_messages.cpp @@ -287,6 +287,12 @@ foo(); #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} foo(); +#pragma omp target parallel map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel'}} + foo(); +#pragma omp target parallel map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel'}} + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_simd_map_messages.cpp b/clang/test/OpenMP/target_simd_map_messages.cpp --- a/clang/test/OpenMP/target_simd_map_messages.cpp +++ b/clang/test/OpenMP/target_simd_map_messages.cpp @@ -276,6 +276,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target simd map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target simd'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target simd map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target simd'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_teams_distribute_map_messages.cpp b/clang/test/OpenMP/target_teams_distribute_map_messages.cpp --- a/clang/test/OpenMP/target_teams_distribute_map_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_map_messages.cpp @@ -288,6 +288,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp --- a/clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp @@ -288,6 +288,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute parallel for map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute parallel for map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp --- a/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp +++ b/clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp @@ -288,6 +288,14 @@ for (i = 0; i < argc; ++i) foo(); #pragma omp target teams distribute parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} for (i = 0; i < argc; ++i) foo(); +#pragma omp target teams distribute parallel for simd map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams distribute parallel for simd'}} + for (i = 0; i < argc; ++i) + foo(); +#pragma omp target teams distribute parallel for simd map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams distribute parallel for simd'}} + for (i = 0; i < argc; ++i) + foo(); return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } diff --git a/clang/test/OpenMP/target_teams_map_messages.cpp b/clang/test/OpenMP/target_teams_map_messages.cpp --- a/clang/test/OpenMP/target_teams_map_messages.cpp +++ b/clang/test/OpenMP/target_teams_map_messages.cpp @@ -580,6 +580,13 @@ #pragma omp target teams map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}} {} +#pragma omp target teams map(delete \ + : j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target teams'}} + {} +#pragma omp target teams map(release \ + : j) // expected-error {{map type 'release' is not allowed for '#pragma omp target teams'}} + {} + return tmain(argc)+tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}} } #endif