@@ -4228,13 +4228,20 @@ bool Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data) {
4228
4228
return T.consumeClose ();
4229
4229
}
4230
4230
4231
+ static OpenMPMapClauseKind isMapType (Parser &P);
4232
+
4231
4233
// / Parse map-type-modifiers in map clause.
4232
- // / map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
4234
+ // / map([ [map-type-modifier[,] [map-type-modifier[,] ...] [ map-type] : ] list)
4233
4235
// / where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
4234
4236
// / present
4237
+ // / where, map-type ::= alloc | delete | from | release | to | tofrom
4235
4238
bool Parser::parseMapTypeModifiers (SemaOpenMP::OpenMPVarListDataTy &Data) {
4239
+ bool HasMapType = false ;
4240
+ SourceLocation PreMapLoc = Tok.getLocation ();
4241
+ StringRef PreMapName = " " ;
4236
4242
while (getCurToken ().isNot (tok::colon)) {
4237
4243
OpenMPMapModifierKind TypeModifier = isMapModifier (*this );
4244
+ OpenMPMapClauseKind MapKind = isMapType (*this );
4238
4245
if (TypeModifier == OMPC_MAP_MODIFIER_always ||
4239
4246
TypeModifier == OMPC_MAP_MODIFIER_close ||
4240
4247
TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4257,6 +4264,19 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4257
4264
Diag (Data.MapTypeModifiersLoc .back (), diag::err_omp_missing_comma)
4258
4265
<< " map type modifier" ;
4259
4266
4267
+ } else if (getLangOpts ().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
4268
+ if (!HasMapType) {
4269
+ HasMapType = true ;
4270
+ Data.ExtraModifier = MapKind;
4271
+ MapKind = OMPC_MAP_unknown;
4272
+ PreMapLoc = Tok.getLocation ();
4273
+ PreMapName = Tok.getIdentifierInfo ()->getName ();
4274
+ } else {
4275
+ Diag (Tok, diag::err_omp_more_one_map_type);
4276
+ Diag (PreMapLoc, diag::note_previous_map_type_specified_here)
4277
+ << PreMapName;
4278
+ }
4279
+ ConsumeToken ();
4260
4280
} else {
4261
4281
// For the case of unknown map-type-modifier or a map-type.
4262
4282
// Map-type is followed by a colon; the function returns when it
@@ -4267,8 +4287,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4267
4287
continue ;
4268
4288
}
4269
4289
// Potential map-type token as it is followed by a colon.
4270
- if (PP.LookAhead (0 ).is (tok::colon))
4271
- return false ;
4290
+ if (PP.LookAhead (0 ).is (tok::colon)) {
4291
+ if (getLangOpts ().OpenMP >= 60 ) {
4292
+ break ;
4293
+ } else {
4294
+ return false ;
4295
+ }
4296
+ }
4297
+
4272
4298
Diag (Tok, diag::err_omp_unknown_map_type_modifier)
4273
4299
<< (getLangOpts ().OpenMP >= 51 ? (getLangOpts ().OpenMP >= 52 ? 2 : 1 )
4274
4300
: 0 )
@@ -4278,6 +4304,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4278
4304
if (getCurToken ().is (tok::comma))
4279
4305
ConsumeToken ();
4280
4306
}
4307
+ if (getLangOpts ().OpenMP >= 60 && !HasMapType) {
4308
+ if (!Tok.is (tok::colon)) {
4309
+ Diag (Tok, diag::err_omp_unknown_map_type);
4310
+ ConsumeToken ();
4311
+ } else {
4312
+ Data.ExtraModifier = OMPC_MAP_unknown;
4313
+ }
4314
+ }
4281
4315
return false ;
4282
4316
}
4283
4317
@@ -4289,13 +4323,12 @@ static OpenMPMapClauseKind isMapType(Parser &P) {
4289
4323
if (!Tok.isOneOf (tok::identifier, tok::kw_delete))
4290
4324
return OMPC_MAP_unknown;
4291
4325
Preprocessor &PP = P.getPreprocessor ();
4292
- OpenMPMapClauseKind MapType =
4293
- static_cast <OpenMPMapClauseKind>(getOpenMPSimpleClauseType (
4294
- OMPC_map, PP.getSpelling (Tok), P.getLangOpts ()));
4326
+ unsigned MapType =
4327
+ getOpenMPSimpleClauseType (OMPC_map, PP.getSpelling (Tok), P.getLangOpts ());
4295
4328
if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_from ||
4296
4329
MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc ||
4297
4330
MapType == OMPC_MAP_delete || MapType == OMPC_MAP_release)
4298
- return MapType;
4331
+ return static_cast <OpenMPMapClauseKind>( MapType) ;
4299
4332
return OMPC_MAP_unknown;
4300
4333
}
4301
4334
@@ -4679,8 +4712,10 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
4679
4712
// Only parse map-type-modifier[s] and map-type if a colon is present in
4680
4713
// the map clause.
4681
4714
if (ColonPresent) {
4715
+ if (getLangOpts ().OpenMP >= 60 && getCurToken ().is (tok::colon))
4716
+ Diag (Tok, diag::err_omp_map_modifier_specification_list);
4682
4717
IsInvalidMapperModifier = parseMapTypeModifiers (Data);
4683
- if (!IsInvalidMapperModifier)
4718
+ if (getLangOpts (). OpenMP < 60 && !IsInvalidMapperModifier)
4684
4719
parseMapType (*this , Data);
4685
4720
else
4686
4721
SkipUntil (tok::colon, tok::annot_pragma_openmp_end, StopBeforeMatch);
0 commit comments