@@ -4208,13 +4208,20 @@ bool Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data) {
4208
4208
return T.consumeClose ();
4209
4209
}
4210
4210
4211
+ static OpenMPMapClauseKind isMapType (Parser &P);
4212
+
4211
4213
// / Parse map-type-modifiers in map clause.
4212
- // / map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
4214
+ // / map([ [map-type-modifier[,] [map-type-modifier[,] ...] [ map-type] : ] list)
4213
4215
// / where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
4214
4216
// / present
4217
+ // / where, map-type ::= alloc | delete | from | release | to | tofrom
4215
4218
bool Parser::parseMapTypeModifiers (SemaOpenMP::OpenMPVarListDataTy &Data) {
4219
+ bool HasMapType = false ;
4220
+ SourceLocation PreMapLoc = Tok.getLocation ();
4221
+ StringRef PreMapName = " " ;
4216
4222
while (getCurToken ().isNot (tok::colon)) {
4217
4223
OpenMPMapModifierKind TypeModifier = isMapModifier (*this );
4224
+ OpenMPMapClauseKind MapKind = isMapType (*this );
4218
4225
if (TypeModifier == OMPC_MAP_MODIFIER_always ||
4219
4226
TypeModifier == OMPC_MAP_MODIFIER_close ||
4220
4227
TypeModifier == OMPC_MAP_MODIFIER_present ||
@@ -4237,6 +4244,19 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4237
4244
Diag (Data.MapTypeModifiersLoc .back (), diag::err_omp_missing_comma)
4238
4245
<< " map type modifier" ;
4239
4246
4247
+ } else if (getLangOpts ().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
4248
+ if (!HasMapType) {
4249
+ HasMapType = true ;
4250
+ Data.ExtraModifier = MapKind;
4251
+ MapKind = OMPC_MAP_unknown;
4252
+ PreMapLoc = Tok.getLocation ();
4253
+ PreMapName = Tok.getIdentifierInfo ()->getName ();
4254
+ } else {
4255
+ Diag (Tok, diag::err_omp_more_one_map_type);
4256
+ Diag (PreMapLoc, diag::note_previous_map_type_specified_here)
4257
+ << PreMapName;
4258
+ }
4259
+ ConsumeToken ();
4240
4260
} else {
4241
4261
// For the case of unknown map-type-modifier or a map-type.
4242
4262
// Map-type is followed by a colon; the function returns when it
@@ -4247,8 +4267,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4247
4267
continue ;
4248
4268
}
4249
4269
// Potential map-type token as it is followed by a colon.
4250
- if (PP.LookAhead (0 ).is (tok::colon))
4251
- return false ;
4270
+ if (PP.LookAhead (0 ).is (tok::colon)) {
4271
+ if (getLangOpts ().OpenMP >= 60 ) {
4272
+ break ;
4273
+ } else {
4274
+ return false ;
4275
+ }
4276
+ }
4277
+
4252
4278
Diag (Tok, diag::err_omp_unknown_map_type_modifier)
4253
4279
<< (getLangOpts ().OpenMP >= 51 ? (getLangOpts ().OpenMP >= 52 ? 2 : 1 )
4254
4280
: 0 )
@@ -4258,6 +4284,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
4258
4284
if (getCurToken ().is (tok::comma))
4259
4285
ConsumeToken ();
4260
4286
}
4287
+ if (getLangOpts ().OpenMP >= 60 && !HasMapType) {
4288
+ if (!Tok.is (tok::colon)) {
4289
+ Diag (Tok, diag::err_omp_unknown_map_type);
4290
+ ConsumeToken ();
4291
+ } else {
4292
+ Data.ExtraModifier = OMPC_MAP_unknown;
4293
+ }
4294
+ }
4261
4295
return false ;
4262
4296
}
4263
4297
@@ -4269,13 +4303,12 @@ static OpenMPMapClauseKind isMapType(Parser &P) {
4269
4303
if (!Tok.isOneOf (tok::identifier, tok::kw_delete))
4270
4304
return OMPC_MAP_unknown;
4271
4305
Preprocessor &PP = P.getPreprocessor ();
4272
- OpenMPMapClauseKind MapType =
4273
- static_cast <OpenMPMapClauseKind>(getOpenMPSimpleClauseType (
4274
- OMPC_map, PP.getSpelling (Tok), P.getLangOpts ()));
4306
+ unsigned MapType =
4307
+ getOpenMPSimpleClauseType (OMPC_map, PP.getSpelling (Tok), P.getLangOpts ());
4275
4308
if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_from ||
4276
4309
MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc ||
4277
4310
MapType == OMPC_MAP_delete || MapType == OMPC_MAP_release)
4278
- return MapType;
4311
+ return static_cast <OpenMPMapClauseKind>( MapType) ;
4279
4312
return OMPC_MAP_unknown;
4280
4313
}
4281
4314
@@ -4659,8 +4692,10 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
4659
4692
// Only parse map-type-modifier[s] and map-type if a colon is present in
4660
4693
// the map clause.
4661
4694
if (ColonPresent) {
4695
+ if (getLangOpts ().OpenMP >= 60 && getCurToken ().is (tok::colon))
4696
+ Diag (Tok, diag::err_omp_map_modifier_specification_list);
4662
4697
IsInvalidMapperModifier = parseMapTypeModifiers (Data);
4663
- if (!IsInvalidMapperModifier)
4698
+ if (getLangOpts (). OpenMP < 60 && !IsInvalidMapperModifier)
4664
4699
parseMapType (*this , Data);
4665
4700
else
4666
4701
SkipUntil (tok::colon, tok::annot_pragma_openmp_end, StopBeforeMatch);
0 commit comments