]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fix PR34926: Fix handling of the array sections passed as
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 12 Oct 2017 15:18:41 +0000 (15:18 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 12 Oct 2017 15:18:41 +0000 (15:18 +0000)
function params.

Codegen could crash if the array section base expression is the
function parameter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315586 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/OpenMP/parallel_reduction_codegen.cpp

index 798a2ef0c5d2424be7eedb4df6117d114e1aa9d4..0f2e328effc5aa4cc1ceba9f30ebc8bf07e98ca1 100644 (file)
@@ -3349,12 +3349,7 @@ static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base,
 
 LValue CodeGenFunction::EmitOMPArraySectionExpr(const OMPArraySectionExpr *E,
                                                 bool IsLowerBound) {
-  QualType BaseTy;
-  if (auto *ASE =
-          dyn_cast<OMPArraySectionExpr>(E->getBase()->IgnoreParenImpCasts()))
-    BaseTy = OMPArraySectionExpr::getBaseOriginalType(ASE);
-  else
-    BaseTy = E->getBase()->getType();
+  QualType BaseTy = OMPArraySectionExpr::getBaseOriginalType(E->getBase());
   QualType ResultExprTy;
   if (auto *AT = getContext().getAsArrayType(BaseTy))
     ResultExprTy = AT->getElementType();
index e42776c740b55cc23efc8b64c116e1d3d1acaa6a..c4c0ff473a59d4c172ddd6dc593854693de82217 100644 (file)
@@ -80,6 +80,14 @@ struct SST {
 // CHECK-DAG: [[REDUCTION_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 18, i32 0, i32 0, i8*
 // CHECK-DAG: [[REDUCTION_LOCK:@.+]] = common global [8 x i32] zeroinitializer
 
+//CHECK: foo_array_sect
+//CHECK: call void {{.+}}@__kmpc_fork_call(
+//CHECK: ret void
+void foo_array_sect(short x[1]) {
+#pragma omp parallel reduction(+ : x[:])
+  {}
+}
+
 template <typename T>
 T tmain() {
   T t;