aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <tstellar@redhat.com>2017-11-13 23:26:36 +0000
committerTom Stellard <tstellar@redhat.com>2017-11-13 23:26:36 +0000
commit9bc8cddc289ec7c1eca2221b92218132843d8110 (patch)
treeb6357e829073a5cc15b7e44b261aeb5f269fd118
parentbff911cfa51040c575b06ac2dd167ad8409576e1 (diff)
downloadllvm-9bc8cddc289ec7c1eca2221b92218132843d8110.zip
llvm-9bc8cddc289ec7c1eca2221b92218132843d8110.tar.gz
llvm-9bc8cddc289ec7c1eca2221b92218132843d8110.tar.bz2
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. ------------------------------------------------------------------------ llvm-svn: 318107
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp3
-rw-r--r--clang/test/OpenMP/declare_reduction_codegen.cpp18
2 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 01f574b..38cb454 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/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<bool>(Lookups, [](ValueDecl *D) -> bool {
return !D->isInvalidDecl() &&
diff --git a/clang/test/OpenMP/declare_reduction_codegen.cpp b/clang/test/OpenMP/declare_reduction_codegen.cpp
index 11ce430..daa1fe8 100644
--- a/clang/test/OpenMP/declare_reduction_codegen.cpp
+++ b/clang/test/OpenMP/declare_reduction_codegen.cpp
@@ -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);
}