Author: abataev Date: Fri Aug 25 08:43:55 2017 New Revision: 311777 URL: http://llvm.org/viewvc/llvm-project?rev=311777&view=rev Log: [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. Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=311777&r1=311776&r2=311777&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Aug 25 08:43:55 2017 @@ -9057,7 +9057,8 @@ buildDeclareReductionRef(Sema &SemaRef, PrevD = D; } } - if (Ty->isDependentType() || Ty->isInstantiationDependentType() || + if (SemaRef.CurContext->isDependentContext() || Ty->isDependentType() || + Ty->isInstantiationDependentType() || Ty->containsUnexpandedParameterPack() || filterLookupForUDR<bool>(Lookups, [](ValueDecl *D) -> bool { return !D->isInvalidDecl() && Modified: cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp?rev=311777&r1=311776&r2=311777&view=diff ============================================================================== --- cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp (original) +++ cfe/trunk/test/OpenMP/declare_reduction_codegen.cpp Fri Aug 25 08:43:55 2017 @@ -92,6 +92,22 @@ T foo(T a) { return a; } +struct Summary { + void merge(const Summary& other) {} +}; + +template <typename K> +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<A>(); // CHECK-LABEL: foo return foo(15); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits