r255879 - [OPENMP] Fix for http://llvm.org/PR25142: openmp: Assertion failed: DD && "queried property of class with no definition", file AST/DeclCXX.h

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 16 22:55:08 PST 2015


Author: abataev
Date: Thu Dec 17 00:55:08 2015
New Revision: 255879

URL: http://llvm.org/viewvc/llvm-project?rev=255879&view=rev
Log:
[OPENMP] Fix for http://llvm.org/PR25142: openmp: Assertion failed: DD && "queried property of class with no definition", file AST/DeclCXX.h
Added processing for template specialization during data-sharing attributes analysis

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=255879&r1=255878&r2=255879&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Dec 17 00:55:08 2015
@@ -603,6 +603,9 @@ DSAStackTy::DSAVarData DSAStackTy::getTo
   //  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
   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;

Modified: cfe/trunk/test/OpenMP/parallel_ast_print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_ast_print.cpp?rev=255879&r1=255878&r2=255879&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_ast_print.cpp Thu Dec 17 00:55:08 2015
@@ -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




More information about the cfe-commits mailing list