diff options
author | Samuel Antao <sfantao@us.ibm.com> | 2016-02-27 00:01:58 +0000 |
---|---|---|
committer | Samuel Antao <sfantao@us.ibm.com> | 2016-02-27 00:01:58 +0000 |
commit | f91b1639505183a88b147012068776abf53a37cd (patch) | |
tree | 27bbafa3babec9a33872cf9382355a718db0a4a4 /clang/lib/Parse/ParseOpenMP.cpp | |
parent | 4b618dcc93285a2c1c9233db8f242264473f31b7 (diff) | |
download | bcm5719-llvm-f91b1639505183a88b147012068776abf53a37cd.tar.gz bcm5719-llvm-f91b1639505183a88b147012068776abf53a37cd.zip |
[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
llvm-svn: 262094
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r-- | clang/lib/Parse/ParseOpenMP.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 6d9f08b0a91..d87abb60204 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -1011,17 +1011,24 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, // 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::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, } 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::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind, 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); } |