[clang] a010ef8 - Add map-type check for target and target data directive, by Chi Chun
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 7 04:33:37 PDT 2020
Author: cchen
Date: 2020-04-07T07:15:52-04:00
New Revision: a010ef8bd88fe28908c48362b04f59b89ad41250
URL: https://github.com/llvm/llvm-project/commit/a010ef8bd88fe28908c48362b04f59b89ad41250
DIFF: https://github.com/llvm/llvm-project/commit/a010ef8bd88fe28908c48362b04f59b89ad41250.diff
LOG: Add map-type check for target and target data directive, by Chi Chun
Chen
Reviewers: ABataev, jdoerfert
Reviewed By: ABataev
Subscribers: cfe-commits, dreachem, sandoval
Tags: #clang
Differential Revision: https://reviews.llvm.org/D77581
Added:
Modified:
clang/lib/Sema/SemaOpenMP.cpp
clang/test/Analysis/cfg-openmp.cpp
clang/test/OpenMP/target_data_messages.c
clang/test/OpenMP/target_map_messages.cpp
clang/test/OpenMP/target_parallel_for_map_messages.cpp
clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
clang/test/OpenMP/target_parallel_map_messages.cpp
clang/test/OpenMP/target_simd_map_messages.cpp
clang/test/OpenMP/target_teams_distribute_map_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
clang/test/OpenMP/target_teams_map_messages.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index dfb809e0aaa1..e9b18f6e9307 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -16998,6 +16998,21 @@ static void checkMappableExpressionList(
continue;
}
+ // target, target data
+ // OpenMP 5.0 [2.12.2, Restrictions, p. 163]
+ // OpenMP 5.0 [2.12.5, Restrictions, p. 174]
+ // A map-type in a map clause must be to, from, tofrom or alloc
+ if ((DKind == OMPD_target_data ||
+ isOpenMPTargetExecutionDirective(DKind)) &&
+ !(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/Analysis/cfg-openmp.cpp b/clang/test/Analysis/cfg-openmp.cpp
index 51107e52a7ad..9e61d656698b 100644
--- a/clang/test/Analysis/cfg-openmp.cpp
+++ b/clang/test/Analysis/cfg-openmp.cpp
@@ -462,10 +462,10 @@ void ttd(int argc) {
// CHECK-DAG: [[#TTD+4]]: rd
// CHECK-DAG: [[#TTD+5]]: [B3.[[#TTDB+2]]]
// CHECK-DAG: [[#TTD+6]]: [B3.[[#TTDB]]]
-// CHECK-DAG: [[#TTD+7]]: #pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+: rd) map(release: map)
+// CHECK-DAG: [[#TTD+7]]: #pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+: rd) map(alloc: map)
// CHECK-DAG: for (int i = 0;
// CHECK-DAG: [B3.[[#TTDB+3]]];
-#pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+:rd) map(release:map)
+#pragma omp target teams distribute if(cond) firstprivate(fp) reduction(+:rd) map(alloc:map)
for (int i = 0; i < 10; ++i)
argc = x;
}
@@ -486,10 +486,10 @@ void ttdpf(int argc) {
// CHECK-DAG: [[#TTDPF+4]]: rd
// CHECK-DAG: [[#TTDPF+5]]: [B3.[[#TTDPFB+2]]]
// CHECK-DAG: [[#TTDPF+6]]: [B3.[[#TTDPFB]]]
-// CHECK-DAG: [[#TTDPF+7]]: #pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+: rd) map(delete: map)
+// CHECK-DAG: [[#TTDPF+7]]: #pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+: rd) map(alloc: map)
// CHECK-DAG: for (int i = 0;
// CHECK-DAG: [B3.[[#TTDPFB+3]]];
-#pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+:rd) map(delete:map)
+#pragma omp target teams distribute parallel for if(cond) firstprivate(fp) reduction(+:rd) map(alloc:map)
for (int i = 0; i < 10; ++i)
argc = x;
}
diff --git a/clang/test/OpenMP/target_data_messages.c b/clang/test/OpenMP/target_data_messages.c
index 7dd48f7e507e..32d2c130d4e9 100644
--- a/clang/test/OpenMP/target_data_messages.c
+++ b/clang/test/OpenMP/target_data_messages.c
@@ -35,5 +35,13 @@ int main(int argc, char **argv) {
{
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
index a18590fc85fe..556df1cf3e14 100644
--- a/clang/test/OpenMP/target_map_messages.cpp
+++ b/clang/test/OpenMP/target_map_messages.cpp
@@ -732,6 +732,11 @@ int main(int argc, char **argv) {
#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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
#endif
diff --git a/clang/test/OpenMP/target_parallel_for_map_messages.cpp b/clang/test/OpenMP/target_parallel_for_map_messages.cpp
index 9269e7f545ca..0d75d702f78c 100644
--- a/clang/test/OpenMP/target_parallel_for_map_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_for_map_messages.cpp
@@ -288,6 +288,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' 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
index b2a8e6b99fff..8156ad8f308c 100644
--- 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,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
diff --git a/clang/test/OpenMP/target_parallel_map_messages.cpp b/clang/test/OpenMP/target_parallel_map_messages.cpp
index 7d5138aa2089..c35bb99d8d59 100644
--- a/clang/test/OpenMP/target_parallel_map_messages.cpp
+++ b/clang/test/OpenMP/target_parallel_map_messages.cpp
@@ -287,6 +287,10 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
diff --git a/clang/test/OpenMP/target_simd_map_messages.cpp b/clang/test/OpenMP/target_simd_map_messages.cpp
index 29074b6e36d2..b8ee39aa03d3 100644
--- a/clang/test/OpenMP/target_simd_map_messages.cpp
+++ b/clang/test/OpenMP/target_simd_map_messages.cpp
@@ -276,6 +276,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
diff --git a/clang/test/OpenMP/target_teams_distribute_map_messages.cpp b/clang/test/OpenMP/target_teams_distribute_map_messages.cpp
index e062aa340ea2..d5f87f74672b 100644
--- a/clang/test/OpenMP/target_teams_distribute_map_messages.cpp
+++ b/clang/test/OpenMP/target_teams_distribute_map_messages.cpp
@@ -288,6 +288,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' 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
index 8ded150c7b46..0be31256a42a 100644
--- 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,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' 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
index 561c36b304af..25c5d938d915 100644
--- 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,12 @@ int main(int argc, char **argv) {
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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
diff --git a/clang/test/OpenMP/target_teams_map_messages.cpp b/clang/test/OpenMP/target_teams_map_messages.cpp
index 15ca431696b5..ec89831f691f 100644
--- a/clang/test/OpenMP/target_teams_map_messages.cpp
+++ b/clang/test/OpenMP/target_teams_map_messages.cpp
@@ -580,6 +580,11 @@ int main(int argc, char **argv) {
#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<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
}
#endif
More information about the cfe-commits
mailing list