davidsh created this revision. davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev. davidsh added a subscriber: cfe-commits.
Clang segfaults on this case instead of diagnosing because it looks at the specialized template: template <class T> struct MyClass; template<> struct MyClass<int> { virtual void foo() {} }; int main() { MyClass<int> m; #pragma omp target map(m) {} } https://reviews.llvm.org/D25252 Files: lib/Sema/SemaOpenMP.cpp test/OpenMP/target_map_messages.cpp Index: test/OpenMP/target_map_messages.cpp =================================================================== --- test/OpenMP/target_map_messages.cpp +++ test/OpenMP/target_map_messages.cpp @@ -347,6 +347,15 @@ S5(int v):a(v) { } }; +template <class T> +struct S6; + +template<> +struct S6<int> // expected-note {{mappable type cannot be polymorphic}} +{ + virtual void foo(); +}; + S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} @@ -451,6 +460,7 @@ int i; int &j = i; int *k = &j; + S6<int> m; int x; int y; int to, tofrom, always; @@ -513,6 +523,8 @@ {} #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} {} +#pragma omp target map(m) // expected-error {{type 'S6<int>' is not mappable to target}} + {} return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} } #endif Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -10523,9 +10523,6 @@ 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: test/OpenMP/target_map_messages.cpp =================================================================== --- test/OpenMP/target_map_messages.cpp +++ test/OpenMP/target_map_messages.cpp @@ -347,6 +347,15 @@ S5(int v):a(v) { } }; +template <class T> +struct S6; + +template<> +struct S6<int> // expected-note {{mappable type cannot be polymorphic}} +{ + virtual void foo(); +}; + S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} @@ -451,6 +460,7 @@ int i; int &j = i; int *k = &j; + S6<int> m; int x; int y; int to, tofrom, always; @@ -513,6 +523,8 @@ {} #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} {} +#pragma omp target map(m) // expected-error {{type 'S6<int>' is not mappable to target}} + {} return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} } #endif Index: lib/Sema/SemaOpenMP.cpp =================================================================== --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -10523,9 +10523,6 @@ 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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits