diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 | ||||
-rw-r--r-- | clang/test/Analysis/array-struct.c | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 97f4d9fc19c..a99ee888206 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2044,7 +2044,7 @@ void ExprEngine::VisitMemberExpr(const MemberExpr *M, ExplodedNode *Pred, if (!M->isGLValue()) { assert(M->getType()->isArrayType()); const ImplicitCastExpr *PE = - dyn_cast<ImplicitCastExpr>((*I)->getParentMap().getParent(M)); + dyn_cast<ImplicitCastExpr>((*I)->getParentMap().getParentIgnoreParens(M)); if (!PE || PE->getCastKind() != CK_ArrayToPointerDecay) { llvm_unreachable("should always be wrapped in ArrayToPointerDecay"); } diff --git a/clang/test/Analysis/array-struct.c b/clang/test/Analysis/array-struct.c index 28e09ad2e88..18f226a8ae6 100644 --- a/clang/test/Analysis/array-struct.c +++ b/clang/test/Analysis/array-struct.c @@ -135,6 +135,17 @@ void f14() { void bar(int*); +struct s3 gets3() { + struct s3 s; + return s; +} + +void accessArrayFieldNoCrash() { + bar(gets3().a); + bar((gets3().a)); + bar(((gets3().a))); +} + // Test if the array is correctly invalidated. void f15() { int a[10]; |