summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2019-06-21 17:28:41 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2019-06-21 17:28:41 +0000
commitf5019451b3e9236c35c495c2792f314246e46e36 (patch)
tree2a61ad4acd2cf857ed081739a93116e2f9bd9ba2 /lib/Sema/SemaExpr.cpp
parenta6b813593c4296abfeb4d3606b0ed38515e9d1b2 (diff)
downloadclang-f5019451b3e9236c35c495c2792f314246e46e36.tar.gz
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 9b09059c15..8fd7e5eafa 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/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);
}