Bounds check intermediate expressions.

When checking "(a + b) * 0", "a + b" might still overflow.
This commit is contained in:
Nigel Tao committed 2017-06-10 11:41:20 +10:00
1 parent ebf3713555
commit 793eb043a4
4 files changed
+53 -35

No files matched your search

+10
View File
@@ -481,6 +481,16 @@ func (n *TypeExpr) IsRefined() bool {
return t.Key(n.id0>>t.KeyShift) != t.KeyOpenBracket && (n.lhs != nil || n.mhs != nil)
}
func (n *TypeExpr) Unrefined() *TypeExpr {
if !n.IsRefined() {
return n
}
o := *n
o.lhs = nil
o.mhs = nil
return &o
}
func NewTypeExpr(pkgOrDec t.ID, name t.ID, arrayLengthMin *Expr, max *Expr, inner *TypeExpr) *TypeExpr {
return &TypeExpr{
kind: KTypeExpr,