From: Alexey Bataev Date: Thu, 17 Dec 2015 06:55:08 +0000 (+0000) Subject: [OPENMP] Fix for http://llvm.org/PR25142: openmp: Assertion failed: DD && "queried... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ce6306b3d0f1b410e0e1d3317d8bda29c7f4786;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255879 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 01f5d1053d..152c1183da 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -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(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(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; diff --git a/test/OpenMP/parallel_ast_print.cpp b/test/OpenMP/parallel_ast_print.cpp index 0f789db8af..1e46fba48c 100644 --- a/test/OpenMP/parallel_ast_print.cpp +++ b/test/OpenMP/parallel_ast_print.cpp @@ -102,4 +102,22 @@ int main (int argc, char **argv) { return tmain(b, &b) + tmain(x, &x); } +template +struct Foo { + int foo; +}; + +void foo(const Foo &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