Index: lib/CodeGen/CGDecl.cpp =================================================================== --- lib/CodeGen/CGDecl.cpp +++ lib/CodeGen/CGDecl.cpp @@ -1439,6 +1439,10 @@ EmitStoreThroughLValue(rvalue, lvalue, true); return; } + if (dyn_cast(type)) { + if (auto const *A = dyn_cast(type.IgnoreParens())) + type = A->getElementType(); + } switch (getEvaluationKind(type)) { case TEK_Scalar: EmitScalarInit(init, D, lvalue, capturedByInit); Index: test/OpenMP/task_by_reference.cpp =================================================================== --- /dev/null +++ test/OpenMP/task_by_reference.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -verify -fopenmp -o - %s +//expected-no-diagnostics + +extern int printf(const char *, ...); +void traverse(int (&p)[5], int N) { + if (N < 5) { +#pragma omp task + { + traverse(p, N + 1); + } + printf("%d\n", p[N]); + } +} + +int main() { + int root[5] = {1, 2, 3, 4, 5}; + +#pragma omp parallel + { +#pragma omp single + { + traverse(root, 0); + } + } + printf("PASSED\n"); +}