@@ -4519,6 +4519,36 @@ static bool parseStepSize(Parser &P, SemaOpenMP::OpenMPVarListDataTy &Data,
4519
4519
return false ;
4520
4520
}
4521
4521
4522
+ // / Parse 'allocate' clause modifiers.
4523
+ // / If allocator-modifier exists, return an expression for it and set
4524
+ // / Data field noting modifier was specified.
4525
+ // /
4526
+ static ExprResult
4527
+ parseOpenMPAllocateClauseModifiers (Parser &P, OpenMPClauseKind Kind,
4528
+ SemaOpenMP::OpenMPVarListDataTy &Data) {
4529
+ const Token &Tok = P.getCurToken ();
4530
+ Preprocessor &PP = P.getPreprocessor ();
4531
+ ExprResult Tail;
4532
+ auto Modifier = static_cast <OpenMPAllocateClauseModifier>(
4533
+ getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok), P.getLangOpts ()));
4534
+ if (Modifier == OMPC_ALLOCATE_allocator) {
4535
+ Data.AllocClauseModifier = Modifier;
4536
+ P.ConsumeToken ();
4537
+ BalancedDelimiterTracker AllocateT (P, tok::l_paren,
4538
+ tok::annot_pragma_openmp_end);
4539
+ if (Tok.is (tok::l_paren)) {
4540
+ AllocateT.consumeOpen ();
4541
+ Tail = P.ParseAssignmentExpression ();
4542
+ AllocateT.consumeClose ();
4543
+ } else {
4544
+ P.Diag (Tok, diag::err_expected) << tok::l_paren;
4545
+ }
4546
+ } else {
4547
+ Tail = P.ParseAssignmentExpression ();
4548
+ }
4549
+ return Tail;
4550
+ }
4551
+
4522
4552
// / Parses clauses with list.
4523
4553
bool Parser::ParseOpenMPVarList (OpenMPDirectiveKind DKind,
4524
4554
OpenMPClauseKind Kind,
@@ -4800,23 +4830,7 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
4800
4830
// iterator(iterators-definition)
4801
4831
ExprResult Tail;
4802
4832
if (Kind == OMPC_allocate) {
4803
- auto Modifier = static_cast <OpenMPAllocateClauseModifier>(
4804
- getOpenMPSimpleClauseType (Kind, PP.getSpelling (Tok), getLangOpts ()));
4805
- if (Modifier == OMPC_ALLOCATE_allocator) {
4806
- Data.AllocClauseModifier = Modifier;
4807
- ConsumeToken ();
4808
- BalancedDelimiterTracker AllocateT (*this , tok::l_paren,
4809
- tok::annot_pragma_openmp_end);
4810
- if (Tok.is (tok::l_paren)) {
4811
- AllocateT.consumeOpen ();
4812
- Tail = ParseAssignmentExpression ();
4813
- AllocateT.consumeClose ();
4814
- } else {
4815
- Diag (Tok, diag::err_expected) << tok::l_paren;
4816
- }
4817
- } else {
4818
- Tail = ParseAssignmentExpression ();
4819
- }
4833
+ Tail = parseOpenMPAllocateClauseModifiers (*this , Kind, Data);
4820
4834
} else {
4821
4835
HasIterator = true ;
4822
4836
EnterScope (Scope::OpenMPDirectiveScope | Scope::DeclScope);
0 commit comments