[OPENMP] Fix detection of explicit data-sharing attributes in templates.

Fixes a bug with analysis of data-sharing attributes in templates.

llvm-svn: 268020
This commit is contained in:
Alexey Bataev 2016-04-29 09:56:11 +00:00
parent e5966e7309
commit 07b79c24c7
2 changed files with 17 additions and 0 deletions

View File

@ -1416,6 +1416,9 @@ class DSAAttrChecker : public StmtVisitor<DSAAttrChecker, void> {
public:
void VisitDeclRefExpr(DeclRefExpr *E) {
if (E->isTypeDependent() || E->isValueDependent() ||
E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
return;
if (auto *VD = dyn_cast<VarDecl>(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<CXXThisExpr>(E->getBase()->IgnoreParens())) {
if (auto *FD = dyn_cast<FieldDecl>(E->getMemberDecl())) {
auto DVar = Stack->getTopDSA(FD, false);

View File

@ -7,6 +7,17 @@ bool foobool(int argc) {
return argc;
}
template <typename T>
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<int> s(3, 4); // expected-note {{in instantiation of member function 'S<int>::S' requested here}}
struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
extern S1 a;
class S2 {