Fixes for casting when range checking (-r) is turned on.

The code calling and within SizeCast was incorrect when range checking is turned on. It produced a call to the __SHORT macro or __SHORTF function, followed by the expression to be converted. For example,

    a = __SHORTF(b,32768)b
This commit is contained in:
Stefan Vorkoetter 2019-01-03 14:54:10 -05:00 committed by GitHub
parent 8890fe1336
commit 11181eb9c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -241,7 +241,8 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
ELSE ELSE
IF (n.typ.size # to) & ((n.typ.size > OPM.CIntSize) OR (to # OPM.CIntSize)) THEN IF (n.typ.size # to) & ((n.typ.size > OPM.CIntSize) OR (to # OPM.CIntSize)) THEN
OPM.WriteString("(INT"); OPM.WriteInt(to*8); OPM.WriteString(")") OPM.WriteString("(INT"); OPM.WriteInt(to*8); OPM.WriteString(")")
END END;
OPM.Write(OpenParen); Entier(n, MinPrec); OPM.Write(CloseParen)
END END
END SizeCast; END SizeCast;
@ -250,13 +251,13 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
BEGIN from := n^.typ^.form; to := newtype.form; BEGIN from := n^.typ^.form; to := newtype.form;
IF to = OPT.Set THEN IF to = OPT.Set THEN
IF from = OPT.Set THEN (* Sets of different size *) IF from = OPT.Set THEN (* Sets of different size *)
SizeCast(n, newtype.size); Entier(n, 9) SizeCast(n, newtype.size);
ELSE (* Set from integer *) ELSE (* Set from integer *)
OPM.WriteString("__SETOF("); Entier(n, MinPrec); OPM.WriteString("__SETOF("); Entier(n, MinPrec);
OPM.WriteString(","); OPM.WriteInt(newtype.size*8); OPM.Write(CloseParen) OPM.WriteString(","); OPM.WriteInt(newtype.size*8); OPM.Write(CloseParen)
END END
ELSIF to = OPT.Int THEN (* integers of different size *) ELSIF to = OPT.Int THEN (* integers of different size *)
SizeCast(n, newtype.size); Entier(n, 9) SizeCast(n, newtype.size);
ELSIF to = OPT.Char THEN ELSIF to = OPT.Char THEN
IF OPM.ranchk IN OPM.Options THEN OPM.WriteString("__CHR"); IF OPM.ranchk IN OPM.Options THEN OPM.WriteString("__CHR");
IF SideEffects(n) THEN OPM.Write("F") END ; IF SideEffects(n) THEN OPM.Write("F") END ;