diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -15902,20 +15902,25 @@ continue; } - auto *ASE = dyn_cast(SimpleExpr); - if (!RefExpr->IgnoreParenImpCasts()->isLValue() || - (ASE && - !ASE->getBase() - ->getType() - .getNonReferenceType() - ->isPointerType() && - !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) { + if (!RefExpr->IgnoreParenImpCasts()->isLValue()) { Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) << (LangOpts.OpenMP >= 50 ? 1 : 0) << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); continue; } + if (auto *ASE = dyn_cast(SimpleExpr)) { + QualType BaseType = ASE->getBase()->getType(); + if (!BaseType->isDependentType() && + !BaseType.getNonReferenceType()->isPointerType() && + !BaseType.getNonReferenceType()->isArrayType()) { + Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item) + << (LangOpts.OpenMP >= 50 ? 1 : 0) + << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange(); + continue; + } + } + ExprResult Res; { Sema::TentativeAnalysisScope Trap(*this); diff --git a/clang/test/OpenMP/depend_template_subscription.cpp b/clang/test/OpenMP/depend_template_subscription.cpp new file mode 100644 --- /dev/null +++ b/clang/test/OpenMP/depend_template_subscription.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized + +#ifndef HEADER +#define HEADER + +template +void test(double *A, IndexT k) +{ + #pragma omp task depend(out: A[k]) // expected-no-diagnostics + { + ; + } +} + +int driver(double *A) +{ + int k = 0; + test(A, k); + return 0; +} + +#endif \ No newline at end of file