]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix detection of explicit data-sharing attributes in templates.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 29 Apr 2016 09:56:11 +0000 (09:56 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 29 Apr 2016 09:56:11 +0000 (09:56 +0000)
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

lib/Sema/SemaOpenMP.cpp
test/OpenMP/task_firstprivate_messages.cpp

index 7ab511bd8f5ae53b2b7d91889c682be42c934d41..cbcf70b41fc02a8820ce2bd173069584851ebc71 100644 (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);
index ef5f3856430a3643279bd025a87cfeceac06836b..11d8c5789879a610da2077acf0f120cc7075b282 100644 (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 {