fixing two incompatible pointer type warnings from gcc

passing a 2d static array to an open array parameter generated no
(void*) cast, because the condition only checked for VarPar mode.
adding a check for whether the formal element type is composite
(typ^.BaseTyp^.form = OPT.Comp) catches the pointer-indirection
mismatch for nested arrays, matching the fix in ofrontplus fe43645.

assigning a pointer-to-extension to a pointer-to-base failed to
cast when the pointer type was anonymous (strobj = NIL). falling
back to casting through the base type's strobj when the pointer
type itself has no name, matching the fix in ofrontplus 69e7660.

fixes issue #105.
This commit is contained in:
Norayr Chilingarian 2026-07-09 23:50:22 +04:00
parent f6f4c904fa
commit 0db5141423

View file

@ -423,7 +423,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
END END
ELSE ELSE
(* casting of params should be simplified eventually *) (* casting of params should be simplified eventually *)
IF (mode = OPT.VarPar) & (typ # n^.typ) & (prec = MinPrec) THEN OPM.WriteString("(void*)") END IF ((mode = OPT.VarPar) OR (typ^.BaseTyp^.form = OPT.Comp)) & (typ # n^.typ) & (prec = MinPrec) THEN OPM.WriteString("(void*)") END
END; END;
IF (mode = OPT.VarPar) & (n^.class = OPT.Nmop) & (n^.subcl = OPT.val) THEN IF (mode = OPT.VarPar) & (n^.class = OPT.Nmop) & (n^.subcl = OPT.val) THEN
expr(n^.left, prec) (* avoid cast in lvalue *) expr(n^.left, prec) (* avoid cast in lvalue *)
@ -817,8 +817,14 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96
design(l, MinPrec); OPM.WriteString(" = ") design(l, MinPrec); OPM.WriteString(" = ")
END ; END ;
IF l^.typ = r^.typ THEN expr(r, MinPrec) IF l^.typ = r^.typ THEN expr(r, MinPrec)
ELSIF (l^.typ^.form = OPT.Pointer) & (r^.typ^.form # OPT.NilTyp) & (l^.typ^.strobj # NIL) THEN ELSIF (l^.typ^.form = OPT.Pointer) & (r^.typ^.form # OPT.NilTyp) THEN
OPM.Write("("); OPC.Ident(l^.typ^.strobj); OPM.Write(")"); expr(r, MinPrec) IF l^.typ^.strobj # NIL THEN
OPM.Write("("); OPC.Ident(l^.typ^.strobj); OPM.Write(")")
ELSIF (l^.typ^.BaseTyp # NIL) & (l^.typ^.BaseTyp^.strobj # NIL)
& (l^.typ^.BaseTyp # r^.typ^.BaseTyp) THEN
OPM.Write("("); OPC.Ident(l^.typ^.BaseTyp^.strobj); OPM.WriteString("*)")
END;
expr(r, MinPrec)
ELSIF l^.typ^.comp = OPT.Record THEN ELSIF l^.typ^.comp = OPT.Record THEN
OPM.WriteString("*("); OPC.Andent(l^.typ); OPM.WriteString("*)&"); expr(r, 9) OPM.WriteString("*("); OPC.Andent(l^.typ); OPM.WriteString("*)&"); expr(r, 9)
ELSE expr(r, MinPrec) ELSE expr(r, MinPrec)