From 0db514142354bf47e40539fee78d068a0c4eaee2 Mon Sep 17 00:00:00 2001 From: Norayr Chilingarian Date: Thu, 9 Jul 2026 23:50:22 +0400 Subject: [PATCH] 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. --- src/compiler/OPV.Mod | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/compiler/OPV.Mod b/src/compiler/OPV.Mod index abe69fdb..8e30da2b 100644 --- a/src/compiler/OPV.Mod +++ b/src/compiler/OPV.Mod @@ -423,7 +423,7 @@ MODULE OPV; (* J. Templ 16.2.95 / 3.7.96 END ELSE (* 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; IF (mode = OPT.VarPar) & (n^.class = OPT.Nmop) & (n^.subcl = OPT.val) THEN 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(" = ") END ; 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 - OPM.Write("("); OPC.Ident(l^.typ^.strobj); OPM.Write(")"); expr(r, MinPrec) + ELSIF (l^.typ^.form = OPT.Pointer) & (r^.typ^.form # OPT.NilTyp) THEN + 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 OPM.WriteString("*("); OPC.Andent(l^.typ); OPM.WriteString("*)&"); expr(r, 9) ELSE expr(r, MinPrec)