Index: lib/Parse/ParseOpenMP.cpp =================================================================== --- lib/Parse/ParseOpenMP.cpp +++ lib/Parse/ParseOpenMP.cpp @@ -1011,17 +1011,24 @@ // 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(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(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 @@ } 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(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 @@ ConsumeToken(); MapType = static_cast(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); } Index: test/OpenMP/target_enter_data_map_messages.c =================================================================== --- test/OpenMP/target_enter_data_map_messages.c +++ test/OpenMP/target_enter_data_map_messages.c @@ -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) { Index: test/OpenMP/target_exit_data_ast_print.cpp =================================================================== --- test/OpenMP/target_exit_data_ast_print.cpp +++ test/OpenMP/target_exit_data_ast_print.cpp @@ -23,6 +23,10 @@ #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 @@ // 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 @@ // 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 @@ // 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 @@ #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) Index: test/OpenMP/target_exit_data_map_messages.c =================================================================== --- test/OpenMP/target_exit_data_map_messages.c +++ test/OpenMP/target_exit_data_map_messages.c @@ -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) {