r262094 - [OpenMP] Fix parsing of delete map clause modifier in C++ mode.
Samuel Antao via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 26 16:01:59 PST 2016
Author: sfantao
Date: Fri Feb 26 18:01:58 2016
New Revision: 262094
URL: http://llvm.org/viewvc/llvm-project?rev=262094&view=rev
Log:
[OpenMP] Fix parsing of delete map clause modifier in C++ mode.
Summary: The map modifier 'delete' is parser in c++ mode as a delete keyword, which requires special handling in the map clause parsing.
Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev
Subscribers: cfe-commits, fraggamuffin, caomhin
Differential Revision: http://reviews.llvm.org/D17629
Modified:
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
cfe/trunk/test/OpenMP/target_exit_data_map_messages.c
Modified: cfe/trunk/lib/Parse/ParseOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseOpenMP.cpp?rev=262094&r1=262093&r2=262094&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp (original)
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp Fri Feb 26 18:01:58 2016
@@ -1011,17 +1011,24 @@ OMPClause *Parser::ParseOpenMPVarListCla
// Handle map type for map clause.
ColonProtectionRAIIObject ColonRAII(*this);
- // the first identifier may be a list item, a map-type or
- // a map-type-modifier
+ /// The map clause modifier token can be either a identifier or the C++
+ /// delete keyword.
+ auto IsMapClauseModifierToken = [](const Token &Tok) {
+ return Tok.isOneOf(tok::identifier, tok::kw_delete);
+ };
+
+ // The first identifier may be a list item, a map-type or a
+ // map-type-modifier. The map modifier can also be delete which has the same
+ // spelling of the C++ delete keyword.
MapType = static_cast<OpenMPMapClauseKind>(getOpenMPSimpleClauseType(
- Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+ Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
DepLinMapLoc = Tok.getLocation();
bool ColonExpected = false;
- if (Tok.is(tok::identifier)) {
+ if (IsMapClauseModifierToken(Tok)) {
if (PP.LookAhead(0).is(tok::colon)) {
MapType = static_cast<OpenMPMapClauseKind>(getOpenMPSimpleClauseType(
- Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+ Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
if (MapType == OMPC_MAP_unknown) {
Diag(Tok, diag::err_omp_unknown_map_type);
} else if (MapType == OMPC_MAP_always) {
@@ -1029,11 +1036,12 @@ OMPClause *Parser::ParseOpenMPVarListCla
}
ConsumeToken();
} else if (PP.LookAhead(0).is(tok::comma)) {
- if (PP.LookAhead(1).is(tok::identifier) &&
+ if (IsMapClauseModifierToken(PP.LookAhead(1)) &&
PP.LookAhead(2).is(tok::colon)) {
MapTypeModifier =
static_cast<OpenMPMapClauseKind>(getOpenMPSimpleClauseType(
- Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+ Kind,
+ IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
if (MapTypeModifier != OMPC_MAP_always) {
Diag(Tok, diag::err_omp_unknown_map_type_modifier);
MapTypeModifier = OMPC_MAP_unknown;
@@ -1045,7 +1053,7 @@ OMPClause *Parser::ParseOpenMPVarListCla
ConsumeToken();
MapType = static_cast<OpenMPMapClauseKind>(getOpenMPSimpleClauseType(
- Kind, Tok.is(tok::identifier) ? PP.getSpelling(Tok) : ""));
+ Kind, IsMapClauseModifierToken(Tok) ? PP.getSpelling(Tok) : ""));
if (MapType == OMPC_MAP_unknown || MapType == OMPC_MAP_always) {
Diag(Tok, diag::err_omp_unknown_map_type);
}
Modified: cfe/trunk/test/OpenMP/target_enter_data_map_messages.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_enter_data_map_messages.c?rev=262094&r1=262093&r2=262094&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_enter_data_map_messages.c (original)
+++ cfe/trunk/test/OpenMP/target_enter_data_map_messages.c Fri Feb 26 18:01:58 2016
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - -x c++ %s
int main(int argc, char **argv) {
Modified: cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp?rev=262094&r1=262093&r2=262094&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_exit_data_ast_print.cpp Fri Feb 26 18:01:58 2016
@@ -23,6 +23,10 @@ T tmain(T argc, T *argv) {
#pragma omp target exit data map(release: x[0:10], c)
+#pragma omp target exit data map(delete: x[0:10])
+
+#pragma omp target exit data map(always, delete: x[0:10])
+
#pragma omp target exit data map(from: c) map(release: d)
#pragma omp target exit data map(always,release: e)
@@ -71,6 +75,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: #pragma omp target exit data map(from: c)
// CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e)
// CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c)
+// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10])
+// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10])
// CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
// CHECK-NEXT: #pragma omp target exit data map(always,release: e)
// CHECK-NEXT: #pragma omp target exit data nowait map(from: i)
@@ -98,6 +104,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: #pragma omp target exit data map(from: c)
// CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e)
// CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c)
+// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10])
+// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10])
// CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
// CHECK-NEXT: #pragma omp target exit data map(always,release: e)
// CHECK-NEXT: #pragma omp target exit data nowait map(from: i)
@@ -125,6 +133,8 @@ T tmain(T argc, T *argv) {
// CHECK-NEXT: #pragma omp target exit data map(from: c)
// CHECK-NEXT: #pragma omp target exit data map(from: c) if(b > e)
// CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c)
+// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10])
+// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10])
// CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
// CHECK-NEXT: #pragma omp target exit data map(always,release: e)
// CHECK-NEXT: #pragma omp target exit data nowait map(from: i)
@@ -168,6 +178,12 @@ int main (int argc, char **argv) {
#pragma omp target exit data map(from: x[0:10], c)
// CHECK-NEXT: #pragma omp target exit data map(from: x[0:10],c)
+#pragma omp target exit data map(delete: x[0:10])
+// CHECK-NEXT: #pragma omp target exit data map(delete: x[0:10])
+
+#pragma omp target exit data map(always, delete: x[0:10])
+// CHECK-NEXT: #pragma omp target exit data map(always,delete: x[0:10])
+
#pragma omp target exit data map(from: c) map(release: d)
// CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
Modified: cfe/trunk/test/OpenMP/target_exit_data_map_messages.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_exit_data_map_messages.c?rev=262094&r1=262093&r2=262094&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/target_exit_data_map_messages.c (original)
+++ cfe/trunk/test/OpenMP/target_exit_data_map_messages.c Fri Feb 26 18:01:58 2016
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - -x c++ %s
int main(int argc, char **argv) {
More information about the cfe-commits
mailing list