summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-02-15 01:51:24 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-02-15 01:51:24 +0000
commitcfd4553a7cccb7c3a0759be6f4c57c938094310b (patch)
tree8af21957f9ae80f80f907a57a956706f4f66df09 /clang/lib/Sema
parentd5719084451ae227c75b2db7078162f921a5a823 (diff)
downloadbcm5719-llvm-cfd4553a7cccb7c3a0759be6f4c57c938094310b.tar.gz
bcm5719-llvm-cfd4553a7cccb7c3a0759be6f4c57c938094310b.zip
Sema: prevent assertion on stack return checking
In the case that the array indexing itself is within a type dependent context, bail out of the evaluation. We would previously try to symbolically evaluate the expression which would then try to evaluate a non-address expression as an address, triggering an assertion in Asserts builds. We only need to consider the array subscript expression itself as in the case that the base itself being type dependent is handled appropriately in EvalAddr. Resolves PR26599. llvm-svn: 260867
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 227079f342d..db29e720054 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6144,8 +6144,10 @@ static const Expr *EvalVal(const Expr *E,
// Array subscripts are potential references to data on the stack. We
// retrieve the DeclRefExpr* for the array variable if it indeed
// has local storage.
- return EvalAddr(cast<ArraySubscriptExpr>(E)->getBase(), refVars,
- ParentDecl);
+ const auto *ASE = cast<ArraySubscriptExpr>(E);
+ if (ASE->isTypeDependent())
+ return nullptr;
+ return EvalAddr(ASE->getBase(), refVars, ParentDecl);
}
case Stmt::OMPArraySectionExprClass: {
OpenPOWER on IntegriCloud