[OPENMP] Fix for http://llvm.org/PR25142: openmp: Assertion failed: DD && "queried...
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Dec 2015 06:55:08 +0000 (06:55 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 17 Dec 2015 06:55:08 +0000 (06:55 +0000)
Added processing for template specialization during data-sharing attributes analysis

llvm-svn: 255879

clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_ast_print.cpp

index 01f5d1053d6c588851b7bfb2c8177aaf754c9370..152c1183daebad1789396590fd1d2b71d1afb708 100644 (file)
@@ -603,6 +603,9 @@ DSAStackTy::DSAVarData DSAStackTy::getTopDSA(VarDecl *D, bool FromParent) {
   //  shared.
   CXXRecordDecl *RD =
       SemaRef.getLangOpts().CPlusPlus ? Type->getAsCXXRecordDecl() : nullptr;
+  if (auto *CTSD = dyn_cast_or_null<ClassTemplateSpecializationDecl>(RD))
+    if (auto *CTD = CTSD->getSpecializedTemplate())
+      RD = CTD->getTemplatedDecl();
   if (IsConstant &&
       !(SemaRef.getLangOpts().CPlusPlus && RD && RD->hasMutableFields())) {
     // Variables with const-qualified type having no mutable member may be
@@ -8041,6 +8044,9 @@ static bool IsCXXRecordForMappable(Sema &SemaRef, SourceLocation Loc,
   if (!RD || RD->isInvalidDecl())
     return true;
 
+  if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
+    if (auto *CTD = CTSD->getSpecializedTemplate())
+      RD = CTD->getTemplatedDecl();
   auto QTy = SemaRef.Context.getRecordType(RD);
   if (RD->isDynamicClass()) {
     SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy;
index 0f789db8af4da150937bf55d97aa52294cb07fd3..1e46fba48ca31eefa923d83b3c6709b2c3c61000 100644 (file)
@@ -102,4 +102,22 @@ int main (int argc, char **argv) {
   return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
 }
 
+template <class T>
+struct Foo {
+  int foo;
+};
+
+void foo(const Foo<int> &arg) {
+// CHECK: #pragma omp parallel
+#pragma omp parallel
+  {
+// CHECK: #pragma omp for schedule(static)
+#pragma omp for schedule(static)
+    for (int idx = 0; idx < 1234; ++idx) {
+      //arg.foo = idx;
+      idx = arg.foo;
+    }
+  }
+}
+
 #endif