[clang] c74a8ad - [OPENMP]Allow comma in combiner expression.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 07:06:52 PST 2020
Author: Alexey Bataev
Date: 2020-01-08T10:00:11-05:00
New Revision: c74a8adda3bc4fc5714aef14cdcfda944d3038a0
URL: https://github.com/llvm/llvm-project/commit/c74a8adda3bc4fc5714aef14cdcfda944d3038a0
DIFF: https://github.com/llvm/llvm-project/commit/c74a8adda3bc4fc5714aef14cdcfda944d3038a0.diff
LOG: [OPENMP]Allow comma in combiner expression.
Use ParseExpression() instead of ParseAssignmentExpression() to allow
commas in combiner expressions.
Added:
Modified:
clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/declare_reduction_ast_print.cpp
Removed:
################################################################################
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 31ae3af70b71..24855df334f4 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -343,9 +343,8 @@ Parser::ParseOpenMPDeclareReductionDirective(AccessSpecifier AS) {
Scope::OpenMPDirectiveScope);
// Parse <combiner> expression.
Actions.ActOnOpenMPDeclareReductionCombinerStart(getCurScope(), D);
- ExprResult CombinerResult =
- Actions.ActOnFinishFullExpr(ParseAssignmentExpression().get(),
- D->getLocation(), /*DiscardedValue*/ false);
+ ExprResult CombinerResult = Actions.ActOnFinishFullExpr(
+ ParseExpression().get(), D->getLocation(), /*DiscardedValue*/ false);
Actions.ActOnOpenMPDeclareReductionCombinerEnd(D, CombinerResult.get());
if (CombinerResult.isInvalid() && Tok.isNot(tok::r_paren) &&
diff --git a/clang/test/OpenMP/declare_reduction_ast_print.cpp b/clang/test/OpenMP/declare_reduction_ast_print.cpp
index 6344394cfdbf..8de954efd9e7 100644
--- a/clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ b/clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -23,14 +23,24 @@ namespace N1
// CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
// CHECK-NEXT: #pragma omp declare reduction (+ : char : omp_out *= omp_in)
+
template <class T>
class SSS {
public:
#pragma omp declare reduction(fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
- // CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
- // CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
+#pragma omp declare reduction(fun1 : T : omp_out=1, omp_out=foo(omp_in)) initializer(omp_priv = omp_orig + 14)
+ static T foo(T &);
};
+// CHECK: template <class T> class SSS {
+// CHECK: #pragma omp declare reduction (fun : T : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
+// CHECK: #pragma omp declare reduction (fun1 : T : omp_out = 1 , omp_out = foo(omp_in)) initializer(omp_priv = omp_orig + 14)
+// CHECK: };
+// CHECK: template<> class SSS<int> {
+// CHECK: #pragma omp declare reduction (fun : int : omp_out += omp_in) initializer(omp_priv = omp_orig + 15)
+// CHECK: #pragma omp declare reduction (fun1 : int : omp_out = 1 , omp_out = foo(omp_in)) initializer(omp_priv = omp_orig + 14)
+// CHECK: };
+
SSS<int> d;
void init(SSS<int> &lhs, SSS<int> rhs);
More information about the cfe-commits
mailing list