From 10ca3bcc736ce460e5a64b822cdf09a241def7b6 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Wed, 21 Jun 2017 21:15:56 -0500 Subject: [PATCH] Properly generate const-qualified structs and unions. Global structs and unions with the const qualifier were not being generated in object files. This occurred because they were represented as having "defined types" and the code was not handling those types properly. The following example demonstrated this problem: const struct x { int i; } X = {9}; int main(void) { return X.i; } --- Symbol.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Symbol.pas b/Symbol.pas index 66e8e0b..6686a01 100644 --- a/Symbol.pas +++ b/Symbol.pas @@ -447,14 +447,18 @@ procedure DoGlobals; lval: longint; {for converting types} size: longint; {size of the array} sp: identPtr; {pointer to a symbol table entry} + tPtr: typePtr; {type of global array/struct/union} begin {GenArrays} didOne := false; for i := 0 to hashSize do begin sp := table^.buckets[i]; while sp <> nil do begin - if sp^.storage in [global,private] then - if sp^.itype^.kind in [arrayType,structType,unionType] then begin + if sp^.storage in [global,private] then begin + tPtr := sp^.itype; + while tPtr^.kind = definedType do + tPtr := tPtr^.dType; + if tPtr^.kind in [arrayType,structType,unionType] then begin if not didOne then begin if smallMemoryModel then currentSegment := ' ' @@ -507,6 +511,7 @@ procedure DoGlobals; end; {while} end; {else} end; {if} + end; {if} sp := sp^.next; end; {while} end; {for}