From: Alexey Bataev Date: Fri, 29 Apr 2016 09:56:11 +0000 (+0000) Subject: [OPENMP] Fix detection of explicit data-sharing attributes in templates. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32c45b50493dee9cb305610f9ff9d492d83f29e6;p=clang [OPENMP] Fix detection of explicit data-sharing attributes in templates. Fixes a bug with analysis of data-sharing attributes in templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@268020 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 7ab511bd8f..cbcf70b41f 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -1416,6 +1416,9 @@ class DSAAttrChecker : public StmtVisitor { public: void VisitDeclRefExpr(DeclRefExpr *E) { + if (E->isTypeDependent() || E->isValueDependent() || + E->containsUnexpandedParameterPack() || E->isInstantiationDependent()) + return; if (auto *VD = dyn_cast(E->getDecl())) { // Skip internally declared variables. if (VD->isLocalVarDecl() && !CS->capturesVariable(VD)) @@ -1464,6 +1467,9 @@ public: } } void VisitMemberExpr(MemberExpr *E) { + if (E->isTypeDependent() || E->isValueDependent() || + E->containsUnexpandedParameterPack() || E->isInstantiationDependent()) + return; if (isa(E->getBase()->IgnoreParens())) { if (auto *FD = dyn_cast(E->getMemberDecl())) { auto DVar = Stack->getTopDSA(FD, false); diff --git a/test/OpenMP/task_firstprivate_messages.cpp b/test/OpenMP/task_firstprivate_messages.cpp index ef5f385643..11d8c57898 100644 --- a/test/OpenMP/task_firstprivate_messages.cpp +++ b/test/OpenMP/task_firstprivate_messages.cpp @@ -7,6 +7,17 @@ bool foobool(int argc) { return argc; } +template +struct S { + T b; + S(T a, T c) { +#pragma omp task default(none) firstprivate(a, b) + a = b = c; // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} + } +}; + +S s(3, 4); // expected-note {{in instantiation of member function 'S::S' requested here}} + struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} extern S1 a; class S2 {