diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-21 17:28:41 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2019-06-21 17:28:41 +0000 |
commit | 0f21507b44784869232ad5dbb3605d8cb1c956d2 (patch) | |
tree | 7cdb296f889e0648c7f928d8f1259c1507beb952 /clang/lib/Sema/SemaExpr.cpp | |
parent | 6af1be96641f34e10bf3b4866f72571b63fab27c (diff) | |
download | bcm5719-llvm-0f21507b44784869232ad5dbb3605d8cb1c956d2.tar.gz bcm5719-llvm-0f21507b44784869232ad5dbb3605d8cb1c956d2.zip |
[OPENMP]Fix PR42068: Vla type is not captured.
If the variably modified type is declared outside of the captured region
and then used in the cast expression along with array subscript
expression, the type is not captured and it leads to the compiler crash.
llvm-svn: 364080
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 9b09059c153..8fd7e5eafab 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4737,6 +4737,33 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, assert(VK == VK_RValue || LangOpts.CPlusPlus || !ResultType.isCForbiddenLValueType()); + if (LHSExp->IgnoreParenImpCasts()->getType()->isVariablyModifiedType() && + FunctionScopes.size() > 1) { + if (auto *TT = + LHSExp->IgnoreParenImpCasts()->getType()->getAs<TypedefType>()) { + for (auto I = FunctionScopes.rbegin(), + E = std::prev(FunctionScopes.rend()); + I != E; ++I) { + auto *CSI = dyn_cast<CapturingScopeInfo>(*I); + if (CSI == nullptr) + break; + DeclContext *DC = nullptr; + if (auto *LSI = dyn_cast<LambdaScopeInfo>(CSI)) + DC = LSI->CallOperator; + else if (auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) + DC = CRSI->TheCapturedDecl; + else if (auto *BSI = dyn_cast<BlockScopeInfo>(CSI)) + DC = BSI->TheDecl; + if (DC) { + if (DC->containsDecl(TT->getDecl())) + break; + captureVariablyModifiedType( + Context, LHSExp->IgnoreParenImpCasts()->getType(), CSI); + } + } + } + } + return new (Context) ArraySubscriptExpr(LHSExp, RHSExp, ResultType, VK, OK, RLoc); } |