Some bug fixes for ptr arith

This commit is contained in:
caheckman 2020-05-01 14:40:01 -04:00
parent 4f1adfcfc0
commit 5332624de8
2 changed files with 14 additions and 3 deletions

View file

@ -5928,9 +5928,16 @@ bool AddTreeState::apply(void)
preventDistribution = true;
spanAddTree(baseOp,1);
}
calcSubtype();
}
if (!valid) {
// Distribution transforms were made
ostringstream s;
s << "Problems distributing in pointer arithmetic at ";
baseOp->getAddr().printRaw(s);
data.warningHeader(s.str());
return true;
}
if (!valid)
throw LowlevelError("Problems distributing in ptrarith");
buildTree();
return true;
}

View file

@ -1939,10 +1939,14 @@ Datatype *TypeFactory::downChain(Datatype *ptrtype,uintb &off)
if (ptrtype->metatype != TYPE_PTR) return (Datatype *)0;
TypePointer *ptype = (TypePointer *)ptrtype;
Datatype *pt = ptype->ptrto;
// If we know we have exactly one of an array, strip the array to get pointer to element
bool doStrip = (pt->getMetatype() != TYPE_ARRAY);
pt = pt->getSubType(off,&off);
if (pt == (Datatype *)0)
return (Datatype *)0;
return getTypePointerStripArray(ptype->size,pt,ptype->getWordSize());
if (doStrip)
return getTypePointerStripArray(ptype->size, pt, ptype->getWordSize());
return getTypePointer(ptype->size,pt,ptype->getWordSize());
}
/// The data-type propagation system can push around data-types that are \e partial or are