blob: f1b61077b377a5ce53470dbaf385301c758e23e3 [file] [log] [blame]
Alexey Bataevc6400582013-03-22 06:34:35 +00001//===--- ParseOpenMP.cpp - OpenMP directives parsing ----------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9/// \file
10/// \brief This file implements parsing of all OpenMP directives and clauses.
11///
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/ASTConsumer.h"
Stephen Hines651f13c2014-04-23 16:59:28 -070015#include "RAIIObjectsForParser.h"
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000016#include "clang/AST/StmtOpenMP.h"
Alexey Bataevc6400582013-03-22 06:34:35 +000017#include "clang/Parse/ParseDiagnostic.h"
Alexey Bataev6af701f2013-05-13 04:18:18 +000018#include "clang/Parse/Parser.h"
19#include "clang/Sema/Scope.h"
20#include "llvm/ADT/PointerIntPair.h"
Alexey Bataevc6400582013-03-22 06:34:35 +000021using namespace clang;
22
23//===----------------------------------------------------------------------===//
24// OpenMP declarative directives.
25//===----------------------------------------------------------------------===//
26
Alexey Bataev6af701f2013-05-13 04:18:18 +000027/// \brief Parsing of declarative OpenMP directives.
28///
29/// threadprivate-directive:
30/// annot_pragma_openmp 'threadprivate' simple-variable-list
Alexey Bataevc6400582013-03-22 06:34:35 +000031///
32Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirective() {
33 assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
Alexey Bataev8fe24752013-11-18 08:17:37 +000034 ParenBraceBracketBalancer BalancerRAIIObj(*this);
Alexey Bataevc6400582013-03-22 06:34:35 +000035
36 SourceLocation Loc = ConsumeToken();
Alexey Bataev6af701f2013-05-13 04:18:18 +000037 SmallVector<Expr *, 5> Identifiers;
38 OpenMPDirectiveKind DKind = Tok.isAnnotation() ?
39 OMPD_unknown :
40 getOpenMPDirectiveKind(PP.getSpelling(Tok));
41
42 switch (DKind) {
Alexey Bataevc6400582013-03-22 06:34:35 +000043 case OMPD_threadprivate:
44 ConsumeToken();
Alexey Bataev6af701f2013-05-13 04:18:18 +000045 if (!ParseOpenMPSimpleVarList(OMPD_threadprivate, Identifiers, true)) {
Alexey Bataevc6400582013-03-22 06:34:35 +000046 // The last seen token is annot_pragma_openmp_end - need to check for
47 // extra tokens.
48 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
49 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
50 << getOpenMPDirectiveName(OMPD_threadprivate);
Alexey Bataev8fe24752013-11-18 08:17:37 +000051 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataevc6400582013-03-22 06:34:35 +000052 }
Alexey Bataev6af701f2013-05-13 04:18:18 +000053 // Skip the last annot_pragma_openmp_end.
Alexey Bataevc6400582013-03-22 06:34:35 +000054 ConsumeToken();
55 return Actions.ActOnOpenMPThreadprivateDirective(Loc,
Alexey Bataevc6400582013-03-22 06:34:35 +000056 Identifiers);
57 }
58 break;
59 case OMPD_unknown:
60 Diag(Tok, diag::err_omp_unknown_directive);
61 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000062 case OMPD_parallel:
Stephen Hines651f13c2014-04-23 16:59:28 -070063 case OMPD_simd:
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000064 case OMPD_task:
65 case NUM_OPENMP_DIRECTIVES:
Alexey Bataevc6400582013-03-22 06:34:35 +000066 Diag(Tok, diag::err_omp_unexpected_directive)
Alexey Bataev6af701f2013-05-13 04:18:18 +000067 << getOpenMPDirectiveName(DKind);
Alexey Bataevc6400582013-03-22 06:34:35 +000068 break;
69 }
Alexey Bataev8fe24752013-11-18 08:17:37 +000070 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataevc6400582013-03-22 06:34:35 +000071 return DeclGroupPtrTy();
72}
73
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000074/// \brief Parsing of declarative or executable OpenMP directives.
75///
76/// threadprivate-directive:
77/// annot_pragma_openmp 'threadprivate' simple-variable-list
78/// annot_pragma_openmp_end
79///
80/// parallel-directive:
81/// annot_pragma_openmp 'parallel' {clause} annot_pragma_openmp_end
82///
83StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
84 assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
Alexey Bataev8fe24752013-11-18 08:17:37 +000085 ParenBraceBracketBalancer BalancerRAIIObj(*this);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000086 SmallVector<Expr *, 5> Identifiers;
87 SmallVector<OMPClause *, 5> Clauses;
88 SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>, NUM_OPENMP_CLAUSES>
89 FirstClauses(NUM_OPENMP_CLAUSES);
Alexey Bataev0c018352013-09-06 18:03:48 +000090 const unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
91 Scope::OpenMPDirectiveScope;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000092 SourceLocation Loc = ConsumeToken(), EndLoc;
93 OpenMPDirectiveKind DKind = Tok.isAnnotation() ?
94 OMPD_unknown :
95 getOpenMPDirectiveKind(PP.getSpelling(Tok));
Alexey Bataev0c018352013-09-06 18:03:48 +000096 // Name of critical directive.
97 DeclarationNameInfo DirName;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +000098 StmtResult Directive = StmtError();
99
100 switch (DKind) {
101 case OMPD_threadprivate:
102 ConsumeToken();
103 if (!ParseOpenMPSimpleVarList(OMPD_threadprivate, Identifiers, false)) {
104 // The last seen token is annot_pragma_openmp_end - need to check for
105 // extra tokens.
106 if (Tok.isNot(tok::annot_pragma_openmp_end)) {
107 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
108 << getOpenMPDirectiveName(OMPD_threadprivate);
Alexey Bataev8fe24752013-11-18 08:17:37 +0000109 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000110 }
111 DeclGroupPtrTy Res =
112 Actions.ActOnOpenMPThreadprivateDirective(Loc,
113 Identifiers);
114 Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
115 }
Alexey Bataev8fe24752013-11-18 08:17:37 +0000116 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000117 break;
Stephen Hines651f13c2014-04-23 16:59:28 -0700118 case OMPD_parallel:
119 case OMPD_simd: {
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000120 ConsumeToken();
Alexey Bataev0c018352013-09-06 18:03:48 +0000121
122 Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope());
123
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000124 while (Tok.isNot(tok::annot_pragma_openmp_end)) {
125 OpenMPClauseKind CKind = Tok.isAnnotation() ?
126 OMPC_unknown :
127 getOpenMPClauseKind(PP.getSpelling(Tok));
128 OMPClause *Clause = ParseOpenMPClause(DKind, CKind,
129 !FirstClauses[CKind].getInt());
130 FirstClauses[CKind].setInt(true);
131 if (Clause) {
132 FirstClauses[CKind].setPointer(Clause);
133 Clauses.push_back(Clause);
134 }
135
136 // Skip ',' if any.
137 if (Tok.is(tok::comma))
138 ConsumeToken();
139 }
140 // End location of the directive.
141 EndLoc = Tok.getLocation();
142 // Consume final annot_pragma_openmp_end.
143 ConsumeToken();
144
145 StmtResult AssociatedStmt;
146 bool CreateDirective = true;
147 ParseScope OMPDirectiveScope(this, ScopeFlags);
148 {
149 // The body is a block scope like in Lambdas and Blocks.
150 Sema::CompoundScopeRAII CompoundScope(Actions);
Alexey Bataev0c018352013-09-06 18:03:48 +0000151 Actions.ActOnCapturedRegionStart(Loc, getCurScope(), CR_OpenMP, 1);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000152 Actions.ActOnStartOfCompoundStmt();
153 // Parse statement
154 AssociatedStmt = ParseStatement();
155 Actions.ActOnFinishOfCompoundStmt();
156 if (!AssociatedStmt.isUsable()) {
157 Actions.ActOnCapturedRegionError();
158 CreateDirective = false;
159 } else {
160 AssociatedStmt = Actions.ActOnCapturedRegionEnd(AssociatedStmt.take());
161 CreateDirective = AssociatedStmt.isUsable();
162 }
163 }
164 if (CreateDirective)
165 Directive = Actions.ActOnOpenMPExecutableDirective(DKind, Clauses,
166 AssociatedStmt.take(),
167 Loc, EndLoc);
168
169 // Exit scope.
Alexey Bataev0c018352013-09-06 18:03:48 +0000170 Actions.EndOpenMPDSABlock(Directive.get());
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000171 OMPDirectiveScope.Exit();
172 }
173 break;
174 case OMPD_unknown:
175 Diag(Tok, diag::err_omp_unknown_directive);
Alexey Bataev8fe24752013-11-18 08:17:37 +0000176 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000177 break;
178 case OMPD_task:
179 case NUM_OPENMP_DIRECTIVES:
180 Diag(Tok, diag::err_omp_unexpected_directive)
181 << getOpenMPDirectiveName(DKind);
Alexey Bataev8fe24752013-11-18 08:17:37 +0000182 SkipUntil(tok::annot_pragma_openmp_end);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000183 break;
184 }
185 return Directive;
186}
187
Alexey Bataevc6400582013-03-22 06:34:35 +0000188/// \brief Parses list of simple variables for '#pragma omp threadprivate'
Alexey Bataev6af701f2013-05-13 04:18:18 +0000189/// directive.
Alexey Bataevc6400582013-03-22 06:34:35 +0000190///
Alexey Bataev6af701f2013-05-13 04:18:18 +0000191/// simple-variable-list:
192/// '(' id-expression {, id-expression} ')'
193///
194bool Parser::ParseOpenMPSimpleVarList(OpenMPDirectiveKind Kind,
195 SmallVectorImpl<Expr *> &VarList,
196 bool AllowScopeSpecifier) {
197 VarList.clear();
Alexey Bataevc6400582013-03-22 06:34:35 +0000198 // Parse '('.
Alexey Bataev6af701f2013-05-13 04:18:18 +0000199 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000200 if (T.expectAndConsume(diag::err_expected_lparen_after,
201 getOpenMPDirectiveName(Kind)))
202 return true;
203 bool IsCorrect = true;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000204 bool NoIdentIsFound = true;
Alexey Bataevc6400582013-03-22 06:34:35 +0000205
206 // Read tokens while ')' or annot_pragma_openmp_end is not found.
Alexey Bataev6af701f2013-05-13 04:18:18 +0000207 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::annot_pragma_openmp_end)) {
Alexey Bataevc6400582013-03-22 06:34:35 +0000208 CXXScopeSpec SS;
209 SourceLocation TemplateKWLoc;
210 UnqualifiedId Name;
211 // Read var name.
212 Token PrevTok = Tok;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000213 NoIdentIsFound = false;
Alexey Bataevc6400582013-03-22 06:34:35 +0000214
Alexey Bataev6af701f2013-05-13 04:18:18 +0000215 if (AllowScopeSpecifier && getLangOpts().CPlusPlus &&
216 ParseOptionalCXXScopeSpecifier(SS, ParsedType(), false)) {
Alexey Bataevc6400582013-03-22 06:34:35 +0000217 IsCorrect = false;
218 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alexey Bataev8fe24752013-11-18 08:17:37 +0000219 StopBeforeMatch);
Alexey Bataev6af701f2013-05-13 04:18:18 +0000220 } else if (ParseUnqualifiedId(SS, false, false, false, ParsedType(),
221 TemplateKWLoc, Name)) {
Alexey Bataevc6400582013-03-22 06:34:35 +0000222 IsCorrect = false;
223 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alexey Bataev8fe24752013-11-18 08:17:37 +0000224 StopBeforeMatch);
Alexey Bataev6af701f2013-05-13 04:18:18 +0000225 } else if (Tok.isNot(tok::comma) && Tok.isNot(tok::r_paren) &&
226 Tok.isNot(tok::annot_pragma_openmp_end)) {
227 IsCorrect = false;
228 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alexey Bataev8fe24752013-11-18 08:17:37 +0000229 StopBeforeMatch);
Stephen Hines651f13c2014-04-23 16:59:28 -0700230 Diag(PrevTok.getLocation(), diag::err_expected)
231 << tok::identifier
232 << SourceRange(PrevTok.getLocation(), PrevTokLocation);
Alexey Bataevc6400582013-03-22 06:34:35 +0000233 } else {
Alexey Bataev6af701f2013-05-13 04:18:18 +0000234 DeclarationNameInfo NameInfo = Actions.GetNameFromUnqualifiedId(Name);
235 ExprResult Res = Actions.ActOnOpenMPIdExpression(getCurScope(), SS,
236 NameInfo);
237 if (Res.isUsable())
238 VarList.push_back(Res.take());
Alexey Bataevc6400582013-03-22 06:34:35 +0000239 }
240 // Consume ','.
241 if (Tok.is(tok::comma)) {
242 ConsumeToken();
243 }
Alexey Bataevc6400582013-03-22 06:34:35 +0000244 }
245
Alexey Bataev6af701f2013-05-13 04:18:18 +0000246 if (NoIdentIsFound) {
Stephen Hines651f13c2014-04-23 16:59:28 -0700247 Diag(Tok, diag::err_expected) << tok::identifier;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000248 IsCorrect = false;
249 }
250
251 // Parse ')'.
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000252 IsCorrect = !T.consumeClose() && IsCorrect;
Alexey Bataev6af701f2013-05-13 04:18:18 +0000253
254 return !IsCorrect && VarList.empty();
Alexey Bataevc6400582013-03-22 06:34:35 +0000255}
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000256
257/// \brief Parsing of OpenMP clauses.
258///
259/// clause:
Stephen Hines651f13c2014-04-23 16:59:28 -0700260/// if-clause | num_threads-clause | safelen-clause | default-clause |
261/// private-clause | firstprivate-clause | shared-clause
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000262///
263OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
264 OpenMPClauseKind CKind, bool FirstClause) {
265 OMPClause *Clause = 0;
266 bool ErrorFound = false;
267 // Check if clause is allowed for the given directive.
268 if (CKind != OMPC_unknown && !isAllowedClauseForDirective(DKind, CKind)) {
269 Diag(Tok, diag::err_omp_unexpected_clause)
270 << getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind);
271 ErrorFound = true;
272 }
273
274 switch (CKind) {
Stephen Hines651f13c2014-04-23 16:59:28 -0700275 case OMPC_if:
276 case OMPC_num_threads:
277 case OMPC_safelen:
278 // OpenMP [2.5, Restrictions]
279 // At most one if clause can appear on the directive.
280 // At most one num_threads clause can appear on the directive.
281 // OpenMP [2.8.1, simd construct, Restrictions]
282 // Only one safelen clause can appear on a simd directive.
283 if (!FirstClause) {
284 Diag(Tok, diag::err_omp_more_one_clause)
285 << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind);
286 }
287
288 Clause = ParseOpenMPSingleExprClause(CKind);
289 break;
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000290 case OMPC_default:
Stephen Hines651f13c2014-04-23 16:59:28 -0700291 // OpenMP [2.14.3.1, Restrictions]
292 // Only a single default clause may be specified on a parallel, task or
293 // teams directive.
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000294 if (!FirstClause) {
295 Diag(Tok, diag::err_omp_more_one_clause)
296 << getOpenMPDirectiveName(DKind) << getOpenMPClauseName(CKind);
297 }
298
299 Clause = ParseOpenMPSimpleClause(CKind);
300 break;
301 case OMPC_private:
Alexey Bataevd195bc32013-10-01 05:32:34 +0000302 case OMPC_firstprivate:
Alexey Bataev0c018352013-09-06 18:03:48 +0000303 case OMPC_shared:
Stephen Hines651f13c2014-04-23 16:59:28 -0700304 case OMPC_copyin:
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000305 Clause = ParseOpenMPVarListClause(CKind);
306 break;
307 case OMPC_unknown:
308 Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
309 << getOpenMPDirectiveName(DKind);
Alexey Bataev8fe24752013-11-18 08:17:37 +0000310 SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000311 break;
312 case OMPC_threadprivate:
313 case NUM_OPENMP_CLAUSES:
314 Diag(Tok, diag::err_omp_unexpected_clause)
315 << getOpenMPClauseName(CKind) << getOpenMPDirectiveName(DKind);
Alexey Bataev8fe24752013-11-18 08:17:37 +0000316 SkipUntil(tok::comma, tok::annot_pragma_openmp_end, StopBeforeMatch);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000317 break;
318 }
319 return ErrorFound ? 0 : Clause;
320}
321
Stephen Hines651f13c2014-04-23 16:59:28 -0700322/// \brief Parsing of OpenMP clauses with single expressions like 'if',
323/// 'collapse', 'safelen', 'num_threads', 'simdlen', 'num_teams' or
324/// 'thread_limit'.
325///
326/// if-clause:
327/// 'if' '(' expression ')'
328///
329/// num_threads-clause:
330/// 'num_threads' '(' expression ')'
331///
332/// safelen-clause:
333/// 'safelen' '(' expression ')'
334///
335OMPClause *Parser::ParseOpenMPSingleExprClause(OpenMPClauseKind Kind) {
336 SourceLocation Loc = ConsumeToken();
337
338 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
339 if (T.expectAndConsume(diag::err_expected_lparen_after,
340 getOpenMPClauseName(Kind)))
341 return 0;
342
343 ExprResult LHS(ParseCastExpression(false, false, NotTypeCast));
344 ExprResult Val(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
345
346 // Parse ')'.
347 T.consumeClose();
348
349 if (Val.isInvalid())
350 return 0;
351
352 return Actions.ActOnOpenMPSingleExprClause(Kind, Val.take(), Loc,
353 T.getOpenLocation(),
354 T.getCloseLocation());
355}
356
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000357/// \brief Parsing of simple OpenMP clauses like 'default'.
358///
359/// default-clause:
360/// 'default' '(' 'none' | 'shared' ')
361///
362OMPClause *Parser::ParseOpenMPSimpleClause(OpenMPClauseKind Kind) {
363 SourceLocation Loc = Tok.getLocation();
364 SourceLocation LOpen = ConsumeToken();
365 // Parse '('.
366 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
367 if (T.expectAndConsume(diag::err_expected_lparen_after,
368 getOpenMPClauseName(Kind)))
369 return 0;
370
371 unsigned Type = Tok.isAnnotation() ?
Benjamin Kramer844a5272013-07-20 12:06:17 +0000372 unsigned(OMPC_DEFAULT_unknown) :
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000373 getOpenMPSimpleClauseType(Kind, PP.getSpelling(Tok));
374 SourceLocation TypeLoc = Tok.getLocation();
375 if (Tok.isNot(tok::r_paren) && Tok.isNot(tok::comma) &&
376 Tok.isNot(tok::annot_pragma_openmp_end))
377 ConsumeAnyToken();
378
379 // Parse ')'.
380 T.consumeClose();
381
382 return Actions.ActOnOpenMPSimpleClause(Kind, Type, TypeLoc, LOpen, Loc,
383 Tok.getLocation());
384}
385
386/// \brief Parsing of OpenMP clause 'private', 'firstprivate',
387/// 'shared', 'copyin', or 'reduction'.
388///
389/// private-clause:
390/// 'private' '(' list ')'
Alexey Bataevd195bc32013-10-01 05:32:34 +0000391/// firstprivate-clause:
392/// 'firstprivate' '(' list ')'
Alexey Bataev0c018352013-09-06 18:03:48 +0000393/// shared-clause:
394/// 'shared' '(' list ')'
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000395///
396OMPClause *Parser::ParseOpenMPVarListClause(OpenMPClauseKind Kind) {
397 SourceLocation Loc = Tok.getLocation();
398 SourceLocation LOpen = ConsumeToken();
399 // Parse '('.
400 BalancedDelimiterTracker T(*this, tok::l_paren, tok::annot_pragma_openmp_end);
401 if (T.expectAndConsume(diag::err_expected_lparen_after,
402 getOpenMPClauseName(Kind)))
403 return 0;
404
405 SmallVector<Expr *, 5> Vars;
406 bool IsComma = true;
407 while (IsComma || (Tok.isNot(tok::r_paren) &&
408 Tok.isNot(tok::annot_pragma_openmp_end))) {
409 // Parse variable
410 ExprResult VarExpr = ParseAssignmentExpression();
411 if (VarExpr.isUsable()) {
412 Vars.push_back(VarExpr.take());
413 } else {
414 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
Alexey Bataev8fe24752013-11-18 08:17:37 +0000415 StopBeforeMatch);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000416 }
417 // Skip ',' if any
418 IsComma = Tok.is(tok::comma);
419 if (IsComma) {
420 ConsumeToken();
421 } else if (Tok.isNot(tok::r_paren) &&
422 Tok.isNot(tok::annot_pragma_openmp_end)) {
423 Diag(Tok, diag::err_omp_expected_punc)
Stephen Hines651f13c2014-04-23 16:59:28 -0700424 << getOpenMPClauseName(Kind);
Alexey Bataev4fa7eab2013-07-19 03:13:43 +0000425 }
426 }
427
428 // Parse ')'.
429 T.consumeClose();
430 if (Vars.empty())
431 return 0;
432
433 return Actions.ActOnOpenMPVarListClause(Kind, Vars, Loc, LOpen,
434 Tok.getLocation());
435}
436