diff options
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 6 | ||||
-rw-r--r-- | clang/test/OpenMP/parallel_ast_print.cpp | 18 |
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp index 01f5d1053d6..152c1183dae 100644 --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/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<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; diff --git a/clang/test/OpenMP/parallel_ast_print.cpp b/clang/test/OpenMP/parallel_ast_print.cpp index 0f789db8af4..1e46fba48ca 100644 --- a/clang/test/OpenMP/parallel_ast_print.cpp +++ b/clang/test/OpenMP/parallel_ast_print.cpp @@ -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 |