From 67341cd6d735f99599aab9e9b6a04699860ac5c2 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 13 Nov 2017 23:26:36 +0000 Subject: Merging r311777: ------------------------------------------------------------------------ r311777 | abataev | 2017-08-25 08:43:55 -0700 (Fri, 25 Aug 2017) | 5 lines [OPENMP] Fix for PR34321: ustom OpenMP reduction in C++ template causes SEGFAULT at compile time Compiler crashed when tried to rebuild non-template expression in dependent context. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_50@318107 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaOpenMP.cpp | 3 ++- test/OpenMP/declare_reduction_codegen.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index 01f574b6ae..38cb454316 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -8858,7 +8858,8 @@ buildDeclareReductionRef(Sema &SemaRef, SourceLocation Loc, SourceRange Range, PrevD = D; } } - if (Ty->isDependentType() || Ty->isInstantiationDependentType() || + if (SemaRef.CurContext->isDependentContext() || Ty->isDependentType() || + Ty->isInstantiationDependentType() || Ty->containsUnexpandedParameterPack() || filterLookupForUDR(Lookups, [](ValueDecl *D) -> bool { return !D->isInvalidDecl() && diff --git a/test/OpenMP/declare_reduction_codegen.cpp b/test/OpenMP/declare_reduction_codegen.cpp index 11ce430011..daa1fe8aaf 100644 --- a/test/OpenMP/declare_reduction_codegen.cpp +++ b/test/OpenMP/declare_reduction_codegen.cpp @@ -92,6 +92,22 @@ T foo(T a) { return a; } +struct Summary { + void merge(const Summary& other) {} +}; + +template +void work() { + Summary global_summary; +#pragma omp declare reduction(+ : Summary : omp_out.merge(omp_in)) +#pragma omp parallel for reduction(+ : global_summary) + for (int k = 1; k <= 100; ++k) { + } +} + +struct A {}; + + // CHECK-LABEL: @main int main() { int i = 0; @@ -110,6 +126,8 @@ int main() { // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call( // CHECK: call {{.*}}void (%ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call({{[^@]*}} @{{[^@]*}}[[REGION:@[^ ]+]] + // CHECK-LABEL: work + work(); // CHECK-LABEL: foo return foo(15); } -- cgit v1.2.3