aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-03-17 10:19:46 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-03-17 10:19:46 +0000
commita839dddf9232b652a26c55b4a6ce3f757ae8ab46 (patch)
tree1d2ab393bbca6914e76ffd5b445ff8d7cedc768b /clang/lib/Parse/ParseOpenMP.cpp
parentb59b488e21f7ba968aed86b216024bd490b4daea (diff)
downloadllvm-a839dddf9232b652a26c55b4a6ce3f757ae8ab46.zip
llvm-a839dddf9232b652a26c55b4a6ce3f757ae8ab46.tar.gz
llvm-a839dddf9232b652a26c55b4a6ce3f757ae8ab46.tar.bz2
[OPENMP 4.0] Use 'declare reduction' constructs in 'reduction' clauses.
OpenMP 4.0 allows to define custom reduction operations using '#pragma omp declare reduction' construct. Patch allows to use this custom defined reduction operations in 'reduction' clauses. llvm-svn: 263701
Diffstat (limited to 'clang/lib/Parse/ParseOpenMP.cpp')
-rw-r--r--clang/lib/Parse/ParseOpenMP.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 2d5afd6..7a924b4 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -109,9 +109,16 @@ static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
}
static DeclarationName parseOpenMPReductionId(Parser &P) {
- const Token Tok = P.getCurToken();
+ Token Tok = P.getCurToken();
Sema &Actions = P.getActions();
OverloadedOperatorKind OOK = OO_None;
+ // Allow to use 'operator' keyword for C++ operators
+ bool WithOperator = false;
+ if (Tok.is(tok::kw_operator)) {
+ P.ConsumeToken();
+ Tok = P.getCurToken();
+ WithOperator = true;
+ }
switch (Tok.getKind()) {
case tok::plus: // '+'
OOK = OO_Plus;
@@ -138,7 +145,8 @@ static DeclarationName parseOpenMPReductionId(Parser &P) {
OOK = OO_PipePipe;
break;
case tok::identifier: // identifier
- break;
+ if (!WithOperator)
+ break;
default:
P.Diag(Tok.getLocation(), diag::err_omp_expected_reduction_identifier);
P.SkipUntil(tok::colon, tok::r_paren, tok::annot_pragma_openmp_end,
@@ -181,6 +189,8 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
if (!IsCorrect && Tok.is(tok::annot_pragma_openmp_end))
return DeclGroupPtrTy();
+ IsCorrect = IsCorrect && !Name.isEmpty();
+
if (Tok.is(tok::colon) || Tok.is(tok::annot_pragma_openmp_end)) {
Diag(Tok.getLocation(), diag::err_expected_type);
IsCorrect = false;
@@ -1209,9 +1219,10 @@ OMPClause *Parser::ParseOpenMPVarListClause(OpenMPDirectiveKind DKind,
// Handle reduction-identifier for reduction clause.
if (Kind == OMPC_reduction) {
ColonProtectionRAIIObject ColonRAII(*this);
- if (getLangOpts().CPlusPlus) {
- ParseOptionalCXXScopeSpecifier(ReductionIdScopeSpec, nullptr, false);
- }
+ if (getLangOpts().CPlusPlus)
+ ParseOptionalCXXScopeSpecifier(ReductionIdScopeSpec,
+ /*ObjectType=*/nullptr,
+ /*EnteringContext=*/false);
InvalidReductionId =
ParseReductionId(*this, ReductionIdScopeSpec, ReductionId);
if (InvalidReductionId) {