diff options
author | Anna Zaks <ganna@apple.com> | 2012-09-05 22:31:58 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-09-05 22:31:58 +0000 |
commit | 352c657f789d5633b07d56d76cf78fda05c31353 (patch) | |
tree | 00f6a453108aca84882b69f02fa4a1a00f3e67f0 | |
parent | d91696e8680bbe89df1076fded1bc54104526060 (diff) |
[analyzer] Fix a crash PR13762.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163262 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngineC.cpp | 3 | ||||
-rw-r--r-- | test/Analysis/complex-init-list.cpp | 6 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 3bf16fa0da..00b2f4a6be 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -567,7 +567,8 @@ void ExprEngine::VisitInitListExpr(const InitListExpr *IE, QualType T = getContext().getCanonicalType(IE->getType()); unsigned NumInitElements = IE->getNumInits(); - if (T->isArrayType() || T->isRecordType() || T->isVectorType()) { + if (T->isArrayType() || T->isRecordType() || T->isVectorType() || + T->isAnyComplexType()) { llvm::ImmutableList<SVal> vals = getBasicVals().getEmptySValList(); // Handle base case where the initializer has no elements. diff --git a/test/Analysis/complex-init-list.cpp b/test/Analysis/complex-init-list.cpp new file mode 100644 index 0000000000..24244cb5ef --- /dev/null +++ b/test/Analysis/complex-init-list.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -verify %s + +// Do not crash on initialization to complex numbers. +void init_complex() { + _Complex float valid1 = { 0.0f, 0.0f }; +} |