diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10679,9 +10679,12 @@ def warn_omp_loop_64_bit_var : Warning< "OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed">, InGroup; -def err_omp_unknown_reduction_identifier : Error< +def err_omp_unknown_reduction_identifier_prior_omp_6_0 : Error< "incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', " "'&&', '||', 'min' or 'max' or declare reduction for type %0">; +def err_omp_unknown_reduction_identifier_since_omp_6_0 : Error< + "incorrect reduction identifier, expected one of '+', '*', '&', '|', '^', " + "'&&', '||', 'min' or 'max' or declare reduction for type %0">; def err_omp_not_resolved_reduction_identifier : Error< "unable to resolve declare reduction construct for type %0">; def err_omp_reduction_ref_type_arg : Error< diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -19169,6 +19169,8 @@ // operators: +, -, *, &, |, ^, && and || switch (OOK) { case OO_Plus: + BOK = BO_Add; + break; case OO_Minus: // Minus(-) operator is not supported in TR11 (OpenMP 6.0). Setting BOK to // BO_Comma will automatically diagnose it for OpenMP > 52 as not allowed @@ -19418,9 +19420,14 @@ } if (BOK == BO_Comma && DeclareReductionRef.isUnset()) { // Not allowed reduction identifier is found. - S.Diag(ReductionId.getBeginLoc(), - diag::err_omp_unknown_reduction_identifier) - << Type << ReductionIdRange; + if (S.LangOpts.OpenMP > 52) + S.Diag(ReductionId.getBeginLoc(), + diag::err_omp_unknown_reduction_identifier_since_omp_6_0) + << Type << ReductionIdRange; + else + S.Diag(ReductionId.getBeginLoc(), + diag::err_omp_unknown_reduction_identifier_prior_omp_6_0) + << Type << ReductionIdRange; continue; }