@@ -1473,7 +1473,8 @@ parseOpenMPSimpleClause(Parser &P, OpenMPClauseKind Kind) {
1473
1473
return llvm::None;
1474
1474
1475
1475
unsigned Type = getOpenMPSimpleClauseType (
1476
- Kind, Tok.isAnnotation () ? " " : P.getPreprocessor ().getSpelling (Tok));
1476
+ Kind, Tok.isAnnotation () ? " " : P.getPreprocessor ().getSpelling (Tok),
1477
+ P.getLangOpts ().OpenMP );
1477
1478
SourceLocation TypeLoc = Tok.getLocation ();
1478
1479
if (Tok.isNot (tok::r_paren) && Tok.isNot (tok::comma) &&
1479
1480
Tok.isNot (tok::annot_pragma_openmp_end))
@@ -2871,7 +2872,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2871
2872
Arg[Modifier2] = OMPC_SCHEDULE_MODIFIER_unknown;
2872
2873
Arg[ScheduleKind] = OMPC_SCHEDULE_unknown;
2873
2874
unsigned KindModifier = getOpenMPSimpleClauseType (
2874
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok));
2875
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2876
+ getLangOpts ().OpenMP );
2875
2877
if (KindModifier > OMPC_SCHEDULE_unknown) {
2876
2878
// Parse 'modifier'
2877
2879
Arg[Modifier1] = KindModifier;
@@ -2883,7 +2885,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2883
2885
// Parse ',' 'modifier'
2884
2886
ConsumeAnyToken ();
2885
2887
KindModifier = getOpenMPSimpleClauseType (
2886
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok));
2888
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2889
+ getLangOpts ().OpenMP );
2887
2890
Arg[Modifier2] = KindModifier > OMPC_SCHEDULE_unknown
2888
2891
? KindModifier
2889
2892
: (unsigned )OMPC_SCHEDULE_unknown;
@@ -2898,7 +2901,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2898
2901
else
2899
2902
Diag (Tok, diag::warn_pragma_expected_colon) << " schedule modifier" ;
2900
2903
KindModifier = getOpenMPSimpleClauseType (
2901
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok));
2904
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2905
+ getLangOpts ().OpenMP );
2902
2906
}
2903
2907
Arg[ScheduleKind] = KindModifier;
2904
2908
KLoc[ScheduleKind] = Tok.getLocation ();
@@ -2912,7 +2916,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2912
2916
DelimLoc = ConsumeAnyToken ();
2913
2917
} else if (Kind == OMPC_dist_schedule) {
2914
2918
Arg.push_back (getOpenMPSimpleClauseType (
2915
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok)));
2919
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2920
+ getLangOpts ().OpenMP ));
2916
2921
KLoc.push_back (Tok.getLocation ());
2917
2922
if (Tok.isNot (tok::r_paren) && Tok.isNot (tok::comma) &&
2918
2923
Tok.isNot (tok::annot_pragma_openmp_end))
@@ -2922,7 +2927,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2922
2927
} else if (Kind == OMPC_defaultmap) {
2923
2928
// Get a defaultmap modifier
2924
2929
unsigned Modifier = getOpenMPSimpleClauseType (
2925
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok));
2930
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2931
+ getLangOpts ().OpenMP );
2926
2932
// Set defaultmap modifier to unknown if it is either scalar, aggregate, or
2927
2933
// pointer
2928
2934
if (Modifier < OMPC_DEFAULTMAP_MODIFIER_unknown)
@@ -2940,7 +2946,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2940
2946
Diag (Tok, diag::warn_pragma_expected_colon) << " defaultmap modifier" ;
2941
2947
// Get a defaultmap kind
2942
2948
Arg.push_back (getOpenMPSimpleClauseType (
2943
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok)));
2949
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2950
+ getLangOpts ().OpenMP ));
2944
2951
KLoc.push_back (Tok.getLocation ());
2945
2952
if (Tok.isNot (tok::r_paren) && Tok.isNot (tok::comma) &&
2946
2953
Tok.isNot (tok::annot_pragma_openmp_end))
@@ -2955,7 +2962,8 @@ OMPClause *Parser::ParseOpenMPSingleExprWithArgClause(OpenMPDirectiveKind DKind,
2955
2962
NextToken ().is (tok::colon)) {
2956
2963
// Parse optional <device modifier> ':'
2957
2964
Arg.push_back (getOpenMPSimpleClauseType (
2958
- Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok)));
2965
+ Kind, Tok.isAnnotation () ? " " : PP.getSpelling (Tok),
2966
+ getLangOpts ().OpenMP ));
2959
2967
KLoc.push_back (Tok.getLocation ());
2960
2968
ConsumeAnyToken ();
2961
2969
// Parse ':'
@@ -3057,14 +3065,16 @@ static bool ParseReductionId(Parser &P, CXXScopeSpec &ReductionIdScopeSpec,
3057
3065
}
3058
3066
3059
3067
// / Checks if the token is a valid map-type-modifier.
3068
+ // / FIXME: It will return an OpenMPMapClauseKind if that's what it parses.
3060
3069
static OpenMPMapModifierKind isMapModifier (Parser &P) {
3061
3070
Token Tok = P.getCurToken ();
3062
3071
if (!Tok.is (tok::identifier))
3063
3072
return OMPC_MAP_MODIFIER_unknown;
3064
3073
3065
3074
Preprocessor &PP = P.getPreprocessor ();
3066
- OpenMPMapModifierKind TypeModifier = static_cast <OpenMPMapModifierKind>(
3067
- getOpenMPSimpleClauseType (OMPC_map, PP.getSpelling (Tok)));
3075
+ OpenMPMapModifierKind TypeModifier =
3076
+ static_cast <OpenMPMapModifierKind>(getOpenMPSimpleClauseType (
3077
+ OMPC_map, PP.getSpelling (Tok), P.getLangOpts ().OpenMP ));
3068
3078
return TypeModifier;
3069
3079
}
3070
3080
@@ -3099,12 +3109,14 @@ bool Parser::parseMapperModifier(OpenMPVarListDataTy &Data) {
3099
3109
3100
3110
// / Parse map-type-modifiers in map clause.
3101
3111
// / map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
3102
- // / where, map-type-modifier ::= always | close | mapper(mapper-identifier)
3112
+ // / where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
3113
+ // / present
3103
3114
bool Parser::parseMapTypeModifiers (OpenMPVarListDataTy &Data) {
3104
3115
while (getCurToken ().isNot (tok::colon)) {
3105
3116
OpenMPMapModifierKind TypeModifier = isMapModifier (*this );
3106
3117
if (TypeModifier == OMPC_MAP_MODIFIER_always ||
3107
- TypeModifier == OMPC_MAP_MODIFIER_close) {
3118
+ TypeModifier == OMPC_MAP_MODIFIER_close ||
3119
+ TypeModifier == OMPC_MAP_MODIFIER_present) {
3108
3120
Data.MapTypeModifiers .push_back (TypeModifier);
3109
3121
Data.MapTypeModifiersLoc .push_back (Tok.getLocation ());
3110
3122
ConsumeToken ();
@@ -3126,7 +3138,8 @@ bool Parser::parseMapTypeModifiers(OpenMPVarListDataTy &Data) {
3126
3138
// Potential map-type token as it is followed by a colon.
3127
3139
if (PP.LookAhead (0 ).is (tok::colon))
3128
3140
return false ;
3129
- Diag (Tok, diag::err_omp_unknown_map_type_modifier);
3141
+ Diag (Tok, diag::err_omp_unknown_map_type_modifier)
3142
+ << (getLangOpts ().OpenMP >= 51 ? 1 : 0 );
3130
3143
ConsumeToken ();
3131
3144
}
3132
3145
if (getCurToken ().is (tok::comma))
@@ -3136,14 +3149,16 @@ bool Parser::parseMapTypeModifiers(OpenMPVarListDataTy &Data) {
3136
3149
}
3137
3150
3138
3151
// / Checks if the token is a valid map-type.
3152
+ // / FIXME: It will return an OpenMPMapModifierKind if that's what it parses.
3139
3153
static OpenMPMapClauseKind isMapType (Parser &P) {
3140
3154
Token Tok = P.getCurToken ();
3141
3155
// The map-type token can be either an identifier or the C++ delete keyword.
3142
3156
if (!Tok.isOneOf (tok::identifier, tok::kw_delete))
3143
3157
return OMPC_MAP_unknown;
3144
3158
Preprocessor &PP = P.getPreprocessor ();
3145
- OpenMPMapClauseKind MapType = static_cast <OpenMPMapClauseKind>(
3146
- getOpenMPSimpleClauseType (OMPC_map, PP.getSpelling (Tok)));
3159
+ OpenMPMapClauseKind MapType =
3160
+ static_cast <OpenMPMapClauseKind>(getOpenMPSimpleClauseType (
3161
+ OMPC_map, PP.getSpelling (Tok), P.getLangOpts ().OpenMP ));
3147
3162
return MapType;
3148
3163
}
3149
3164
@@ -3297,7 +3312,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
3297
3312
(Tok.is (tok::identifier) || Tok.is (tok::kw_default)) &&
3298
3313
NextToken ().is (tok::comma)) {
3299
3314
// Parse optional reduction modifier.
3300
- Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok));
3315
+ Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok),
3316
+ getLangOpts ().OpenMP );
3301
3317
Data.ExtraModifierLoc = Tok.getLocation ();
3302
3318
ConsumeToken ();
3303
3319
assert (Tok.is (tok::comma) && " Expected comma." );
@@ -3342,7 +3358,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
3342
3358
// Handle dependency type for depend clause.
3343
3359
ColonProtectionRAIIObject ColonRAII (*this );
3344
3360
Data.ExtraModifier = getOpenMPSimpleClauseType (
3345
- Kind, Tok.is (tok::identifier) ? PP.getSpelling (Tok) : " " );
3361
+ Kind, Tok.is (tok::identifier) ? PP.getSpelling (Tok) : " " ,
3362
+ getLangOpts ().OpenMP );
3346
3363
Data.ExtraModifierLoc = Tok.getLocation ();
3347
3364
if (Data.ExtraModifier == OMPC_DEPEND_unknown) {
3348
3365
SkipUntil (tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
@@ -3367,7 +3384,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
3367
3384
// Try to parse modifier if any.
3368
3385
Data.ExtraModifier = OMPC_LINEAR_val;
3369
3386
if (Tok.is (tok::identifier) && PP.LookAhead (0 ).is (tok::l_paren)) {
3370
- Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok));
3387
+ Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok),
3388
+ getLangOpts ().OpenMP );
3371
3389
Data.ExtraModifierLoc = ConsumeToken ();
3372
3390
LinearT.consumeOpen ();
3373
3391
NeedRParenForLinear = true ;
@@ -3380,7 +3398,8 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
3380
3398
if ((getLangOpts ().OpenMP >= 50 && !isOpenMPDistributeDirective (DKind) &&
3381
3399
!isOpenMPTaskLoopDirective (DKind)) &&
3382
3400
Tok.is (tok::identifier) && PP.LookAhead (0 ).is (tok::colon)) {
3383
- Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok));
3401
+ Data.ExtraModifier = getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok),
3402
+ getLangOpts ().OpenMP );
3384
3403
Data.ExtraModifierLoc = Tok.getLocation ();
3385
3404
ConsumeToken ();
3386
3405
assert (Tok.is (tok::colon) && " Expected colon." );
@@ -3425,13 +3444,15 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
3425
3444
if (Tok.is (tok::identifier)) {
3426
3445
bool IsMapperModifier = false ;
3427
3446
if (Kind == OMPC_to) {
3428
- auto Modifier = static_cast <OpenMPToModifierKind>(
3429
- getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok)));
3447
+ auto Modifier =
3448
+ static_cast <OpenMPToModifierKind>(getOpenMPSimpleClauseType (
3449
+ Kind, PP.getSpelling (Tok), getLangOpts ().OpenMP ));
3430
3450
if (Modifier == OMPC_TO_MODIFIER_mapper)
3431
3451
IsMapperModifier = true ;
3432
3452
} else {
3433
- auto Modifier = static_cast <OpenMPFromModifierKind>(
3434
- getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok)));
3453
+ auto Modifier =
3454
+ static_cast <OpenMPFromModifierKind>(getOpenMPSimpleClauseType (
3455
+ Kind, PP.getSpelling (Tok), getLangOpts ().OpenMP ));
3435
3456
if (Modifier == OMPC_FROM_MODIFIER_mapper)
3436
3457
IsMapperModifier = true ;
3437
3458
}
0 commit comments