Bind the mistakenly generated nonloc::SymbolVal to struct correctly. See the

comments for added test case for details.

llvm-svn: 73189
This commit is contained in:
Zhongxing Xu 2009-06-11 09:11:27 +00:00
parent c3a7992216
commit 519a47d4bd
2 changed files with 13 additions and 0 deletions

View File

@ -1198,6 +1198,9 @@ RegionStoreManager::BindStruct(const GRState* St, const TypedRegion* R, SVal V){
if (V.isUnknown())
return KillStruct(St, R);
if (isa<nonloc::SymbolVal>(V))
return setDefaultValue(St, R, V);
nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
RecordDecl::field_iterator FI = RD->field_begin(getContext()),

View File

@ -148,3 +148,13 @@ void f15() {
if (a[1]) // no-warning
1;
}
struct s3 p[1];
// Code from postgresql.
// Current cast logic of region store mistakenly leaves the final result region
// an ElementRegion of type 'char'. Then load a nonloc::SymbolVal from it and
// assigns to 'a'.
void f16(struct s3 *p) {
struct s3 a = *((struct s3*) ((char*) &p[0]));
}