r357708 - [OPENMP]Fix lookup of the user-defined reductions in C.
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 4 10:28:22 PDT 2019
Author: abataev
Date: Thu Apr 4 10:28:22 2019
New Revision: 357708
URL: http://llvm.org/viewvc/llvm-project?rev=357708&view=rev
Log:
[OPENMP]Fix lookup of the user-defined reductions in C.
Fixed the regression of the lookup of user-defined reductions for C.
Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/declare_reduction_ast_print.c
Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=357708&r1=357707&r2=357708&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Apr 4 10:28:22 2019
@@ -11269,17 +11269,18 @@ buildDeclareReductionRef(Sema &SemaRef,
}
}
// Perform ADL.
- if (SemaRef.getLangOpts().CPlusPlus) {
+ if (SemaRef.getLangOpts().CPlusPlus)
argumentDependentLookup(SemaRef, ReductionId, Loc, Ty, Lookups);
- if (auto *VD = filterLookupForUDReductionAndMapper<ValueDecl *>(
- Lookups, [&SemaRef, Ty](ValueDecl *D) -> ValueDecl * {
- if (!D->isInvalidDecl() &&
- SemaRef.Context.hasSameType(D->getType(), Ty))
- return D;
- return nullptr;
- }))
- return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
- VK_LValue, Loc);
+ if (auto *VD = filterLookupForUDReductionAndMapper<ValueDecl *>(
+ Lookups, [&SemaRef, Ty](ValueDecl *D) -> ValueDecl * {
+ if (!D->isInvalidDecl() &&
+ SemaRef.Context.hasSameType(D->getType(), Ty))
+ return D;
+ return nullptr;
+ }))
+ return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
+ VK_LValue, Loc);
+ if (SemaRef.getLangOpts().CPlusPlus) {
if (auto *VD = filterLookupForUDReductionAndMapper<ValueDecl *>(
Lookups, [&SemaRef, Ty, Loc](ValueDecl *D) -> ValueDecl * {
if (!D->isInvalidDecl() &&
@@ -11893,7 +11894,8 @@ static bool actOnOMPReductionKindClause(
S.ActOnUninitializedDecl(RHSVD);
if (RHSVD->isInvalidDecl())
continue;
- if (!RHSVD->hasInit() && DeclareReductionRef.isUnset()) {
+ if (!RHSVD->hasInit() &&
+ (DeclareReductionRef.isUnset() || !S.LangOpts.CPlusPlus)) {
S.Diag(ELoc, diag::err_omp_reduction_id_not_compatible)
<< Type << ReductionIdRange;
bool IsDecl = !VD || VD->isThisDeclarationADefinition(Context) ==
Modified: cfe/trunk/test/OpenMP/declare_reduction_ast_print.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_reduction_ast_print.c?rev=357708&r1=357707&r2=357708&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_reduction_ast_print.c (original)
+++ cfe/trunk/test/OpenMP/declare_reduction_ast_print.c Thu Apr 4 10:28:22 2019
@@ -43,4 +43,17 @@ int main() {
}
// CHECK: }
+#pragma omp declare reduction(mymin:int \
+ : omp_out = omp_out > omp_in ? omp_in : omp_out) \
+ initializer(omp_priv = 2147483647)
+
+int foo(int argc, char **argv) {
+ int x;
+#pragma omp parallel for reduction(mymin : x)
+ for (int i = 0; i < 1000; i++)
+ ;
+ return 0;
+}
+
+// CHECK: #pragma omp parallel for reduction(mymin: x)
#endif
More information about the cfe-commits
mailing list