[OPENMP] Restore allowing of braced initializers in the declare reduction
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 2 Jan 2020 20:49:08 +0000 (15:49 -0500)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 2 Jan 2020 21:10:17 +0000 (16:10 -0500)
    init.

Braced initializers were not accepted after the last fix in the initialier.Restored previous functionality.

clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/declare_reduction_messages.c

index a62c68b..aaef4cd 100644 (file)
@@ -430,7 +430,7 @@ void Parser::ParseOpenMPReductionInitializerForDecl(VarDecl *OmpPrivParm) {
     }
 
     PreferredType.enterVariableInit(Tok.getLocation(), OmpPrivParm);
-    ExprResult Init = ParseAssignmentExpression();
+    ExprResult Init = ParseInitializer();
 
     if (Init.isInvalid()) {
       SkipUntil(tok::r_paren, tok::annot_pragma_openmp_end, StopBeforeMatch);
index 4a0d6ef..69b73f4 100644 (file)
@@ -45,6 +45,8 @@ struct S {
   int s;
 };
 #pragma omp declare reduction(+: struct S: omp_out.s += omp_in.s) // initializer(omp_priv = { .s = 0 })
+#pragma omp declare reduction(&: struct S: omp_out.s += omp_in.s) initializer(omp_priv = { .s = 0 })
+#pragma omp declare reduction(|: struct S: omp_out.s += omp_in.s) initializer(omp_priv = { 0 })
 
 int fun(int arg) {
   struct S s;// expected-note {{'s' defined here}}