summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOpenMP.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2017-09-21 14:06:59 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2017-09-21 14:06:59 +0000
commit0dce2ea75873f3a1ab6e0a42561b63887231be41 (patch)
tree9cf07d142c3c329e5f1294e30eac79eac7f4af32 /clang/lib/Sema/SemaOpenMP.cpp
parentede43b71f802ad65c030557876939bcc1f7636b8 (diff)
downloadbcm5719-llvm-0dce2ea75873f3a1ab6e0a42561b63887231be41.tar.gz
bcm5719-llvm-0dce2ea75873f3a1ab6e0a42561b63887231be41.zip
[OPENMP] Use canonical declarations for redeclarations checks.
If the captured variable has some redeclarations we may run into the situation where the redeclaration is used instead of the canonical declaration and we may consider this variable as one not captured before. llvm-svn: 313880
Diffstat (limited to 'clang/lib/Sema/SemaOpenMP.cpp')
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 342bd6dce87..e4a57db8da5 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1130,6 +1130,7 @@ bool Sema::IsOpenMPCapturedByRef(ValueDecl *D, unsigned Level) {
bool IsByRef = true;
// Find the directive that is associated with the provided scope.
+ D = cast<ValueDecl>(D->getCanonicalDecl());
auto Ty = D->getType();
if (DSAStack->hasExplicitDirective(isOpenMPTargetExecutionDirective, Level)) {
@@ -1787,6 +1788,7 @@ class DSAAttrChecker : public StmtVisitor<DSAAttrChecker, void> {
CapturedStmt *CS;
llvm::SmallVector<Expr *, 8> ImplicitFirstprivate;
llvm::DenseMap<ValueDecl *, Expr *> VarsWithInheritedDSA;
+ llvm::DenseSet<ValueDecl *> ImplicitDeclarations;
public:
void VisitDeclRefExpr(DeclRefExpr *E) {
@@ -1794,13 +1796,14 @@ public:
E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
return;
if (auto *VD = dyn_cast<VarDecl>(E->getDecl())) {
+ VD = VD->getCanonicalDecl();
// Skip internally declared variables.
if (VD->isLocalVarDecl() && !CS->capturesVariable(VD))
return;
auto DVar = Stack->getTopDSA(VD, false);
// Check if the variable has explicit DSA set and stop analysis if it so.
- if (DVar.RefExpr)
+ if (DVar.RefExpr || !ImplicitDeclarations.insert(VD).second)
return;
auto ELoc = E->getExprLoc();
@@ -1850,7 +1853,7 @@ public:
auto DVar = Stack->getTopDSA(FD, false);
// Check if the variable has explicit DSA set and stop analysis if it
// so.
- if (DVar.RefExpr)
+ if (DVar.RefExpr || !ImplicitDeclarations.insert(FD).second)
return;
auto ELoc = E->getExprLoc();
@@ -2617,7 +2620,7 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
llvm::DenseMap<ValueDecl *, Expr *> VarsWithInheritedDSA;
bool ErrorFound = false;
ClausesWithImplicit.append(Clauses.begin(), Clauses.end());
- if (AStmt) {
+ if (AStmt && !CurContext->isDependentContext()) {
assert(isa<CapturedStmt>(AStmt) && "Captured statement expected");
// Check default data sharing attributes for referenced variables.
OpenPOWER on IntegriCloud