summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2015-08-25 14:24:04 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2015-08-25 14:24:04 +0000
commit1a3320e4639c9f39e85311f41dcd4d5a5c2c7f28 (patch)
tree5e0a2558e01bea5a62f5dc995be8c5c280cc0441 /clang/lib/Parse/ParseExpr.cpp
parentf0c2dd07eaa888ab949f6f1befe3a70e78abc831 (diff)
downloadbcm5719-llvm-1a3320e4639c9f39e85311f41dcd4d5a5c2c7f28.tar.gz
bcm5719-llvm-1a3320e4639c9f39e85311f41dcd4d5a5c2c7f28.zip
[OPENMP 4.0] Initial support for array sections.
Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0). Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions. Differential Revision: http://reviews.llvm.org/D10732 llvm-svn: 245937
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r--clang/lib/Parse/ParseExpr.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index b866798a1c6..ed8073a80c4 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1396,21 +1396,42 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
BalancedDelimiterTracker T(*this, tok::l_square);
T.consumeOpen();
Loc = T.getOpenLocation();
- ExprResult Idx;
+ ExprResult Idx, Length;
+ SourceLocation ColonLoc;
if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
Idx = ParseBraceInitializer();
+ } else if (getLangOpts().OpenMP) {
+ ColonProtectionRAIIObject RAII(*this);
+ // Parse [: or [ expr or [ expr :
+ if (!Tok.is(tok::colon)) {
+ // [ expr
+ Idx = ParseExpression();
+ }
+ if (Tok.is(tok::colon)) {
+ // Consume ':'
+ ColonLoc = ConsumeToken();
+ if (Tok.isNot(tok::r_square))
+ Length = ParseExpression();
+ }
} else
Idx = ParseExpression();
SourceLocation RLoc = Tok.getLocation();
- if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
- LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
- Idx.get(), RLoc);
+ if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
+ Tok.is(tok::r_square)) {
+ if (ColonLoc.isValid()) {
+ LHS = Actions.ActOnOMPArraySectionExpr(LHS.get(), Loc, Idx.get(),
+ ColonLoc, Length.get(), RLoc);
+ } else {
+ LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
+ Idx.get(), RLoc);
+ }
} else {
(void)Actions.CorrectDelayedTyposInExpr(LHS);
(void)Actions.CorrectDelayedTyposInExpr(Idx);
+ (void)Actions.CorrectDelayedTyposInExpr(Length);
LHS = ExprError();
Idx = ExprError();
}
OpenPOWER on IntegriCloud