From 00ace776c4d816cfddf5551cfd5c9af99a978ad7 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 13 Oct 2016 18:39:57 -0500 Subject: [PATCH] Properly support declarations with incomplete structure types that are completed later in the same scope. This fixes a problem with ORCA/C conformance test C5.6.0.1.CC, which was introduced by commit bf9fa66. A slightly more involved fix was needed to preserve the correct behavior while avoiding the memory trashing fixed by that patch. --- Symbol.pas | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Symbol.pas b/Symbol.pas index d0e1d87..8e09fcc 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -1498,7 +1498,7 @@ var begin {ResolveForwardReference} iPtr^.isForwardDeclared := false; {we will succeeed or flag an error...} tPtr := iPtr^.itype; {skip to the struct/union type} -lPtr := tPtr; {initialize it here -- kws} +lPtr := nil; while tPtr^.kind in [pointerType,arrayType,functionType,definedType] do begin lPtr := tPtr; tPtr := tPtr^.pType; @@ -1513,12 +1513,16 @@ if tPtr^.sName <> nil then begin {resolve the forward reference} else begin if sym^.itype = tPtr then tPtr^.sName := nil - else - lPtr^.ptype := sym^.itype; + else begin + tPtr := sym^.itype; + if lPtr <> nil then + lPtr^.ptype := tPtr; + end; {else} end; {else} end; {if} end; {if} -tPtr := lPtr^.pType; {check the field list for other fwd refs} +if lPtr <> nil then + tPtr := lPtr^.pType; {check the field list for other fwd refs} while tPtr^.kind in [pointerType,arrayType,functionType,definedType] do tPtr := tPtr^.pType; if tPtr^.kind in [structType,unionType] then begin