Example #1
0
func checkNoSideEffects(x *cc.Expr, mode int) {
	var before, after []*cc.Stmt
	old := x.String()
	doSideEffects(x, &before, &after, mode)
	if len(before)+len(after) > 0 {
		fprintf(x.Span, "cannot handle side effects in %s", old)
	}
}
Example #2
0
func matchSize(fn *cc.Decl, obj *cc.Expr, objType *cc.Type, siz *cc.Expr) bool {
	switch siz.Op {
	default:
		return false

	case cc.SizeofType:
		// ok if sizeof type of first arg
		return sameType(siz.Type, objType)

	case cc.SizeofExpr:
		// ok if sizeof *firstarg
		y := siz.Left
		if y.Op == cc.Paren {
			y = y.Left
		}
		return obj.String() == y.String()
	}
}