diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-05-06 17:49:22 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-05-06 17:49:22 +0000 |
commit | cf9e7a282b74cd12cd266ab11291a58fdc871976 (patch) | |
tree | bf05b4eedbe1d76d98fe7ef08e485050fd155096 /clang/lib/Sema/SemaOpenMP.cpp | |
parent | 865a39d328c2fa0ce251447bf2d6005dbbfec595 (diff) | |
download | bcm5719-llvm-cf9e7a282b74cd12cd266ab11291a58fdc871976.tar.gz bcm5719-llvm-cf9e7a282b74cd12cd266ab11291a58fdc871976.zip |
[OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.
If the `default(none)` was specified for the construct, we might miss
diagnostic for the globals without explicitly specified data-sharing
attributes. Patch fixes this problem.
llvm-svn: 360061
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 0aebd8e03a6..276f1506c4b 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -1777,10 +1777,15 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D) { DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode()); if (DVarPrivate.CKind != OMPC_unknown && isOpenMPPrivate(DVarPrivate.CKind)) return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl()); + if (VD && DSAStack->getDefaultDSA() == DSA_none) + return VD; DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate, [](OpenMPDirectiveKind) { return true; }, DSAStack->isClauseParsingMode()); - if (DVarPrivate.CKind != OMPC_unknown) + // The variable is not private or it is the variable in the directive with + // default(none) clause and not used in any clause. + if (DVarPrivate.CKind != OMPC_unknown || + (VD && DSAStack->getDefaultDSA() == DSA_none)) return VD ? VD : cast<VarDecl>(DVarPrivate.PrivateCopy->getDecl()); } return nullptr; @@ -4184,6 +4189,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective( for (const auto &P : VarsWithInheritedDSA) { Diag(P.second->getExprLoc(), diag::err_omp_no_dsa_for_variable) << P.first << P.second->getSourceRange(); + Diag(DSAStack->getDefaultDSALocation(), diag::note_omp_default_dsa_none); } ErrorFound = !VarsWithInheritedDSA.empty() || ErrorFound; |