Author: abataev
Date: Fri Apr 29 04:56:11 2016
New Revision: 268020

URL: http://llvm.org/viewvc/llvm-project?rev=268020&view=rev
Log:
[OPENMP] Fix detection of explicit data-sharing attributes in templates.

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

Modified:
    cfe/trunk/lib/Sema/SemaOpenMP.cpp
    cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=268020&r1=268019&r2=268020&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Apr 29 04:56:11 2016
@@ -1416,6 +1416,9 @@ class DSAAttrChecker : public StmtVisito
 
 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);

Modified: cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp?rev=268020&r1=268019&r2=268020&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp Fri Apr 29 04:56:11 
2016
@@ -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 {


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to