mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-06-15 23:29:44 +00:00
Give anonymous structs/unions unique internal names.
This will help deal with initialization of them.
This commit is contained in:
parent
a3c4eeb8f6
commit
4621336c3b
29
Parser.pas
29
Parser.pas
|
@ -182,6 +182,7 @@ type
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
anonNumber: integer; {number for next anonymous struct/union}
|
||||||
firstCompoundStatement: boolean; {are we doing a function level compound statement?}
|
firstCompoundStatement: boolean; {are we doing a function level compound statement?}
|
||||||
fType: typePtr; {return type of the current function}
|
fType: typePtr; {return type of the current function}
|
||||||
functionName: stringPtr; {name of the current function}
|
functionName: stringPtr; {name of the current function}
|
||||||
|
@ -2827,7 +2828,11 @@ var
|
||||||
|
|
||||||
label 1;
|
label 1;
|
||||||
|
|
||||||
|
type
|
||||||
|
anonNameString = packed array [0..11] of char;
|
||||||
|
|
||||||
var
|
var
|
||||||
|
anonName: ^anonNameString; {name for anonymous struct/union field}
|
||||||
bitDisp: integer; {current bit disp}
|
bitDisp: integer; {current bit disp}
|
||||||
disp: longint; {current byte disp}
|
disp: longint; {current byte disp}
|
||||||
done: boolean; {for loop termination}
|
done: boolean; {for loop termination}
|
||||||
|
@ -2857,16 +2862,14 @@ var
|
||||||
tfl: identPtr; {for traversing field list}
|
tfl: identPtr; {for traversing field list}
|
||||||
|
|
||||||
begin {AddField}
|
begin {AddField}
|
||||||
if variable^.name^ <> '~anonymous' then begin
|
tfl := fl; {(check for dups)}
|
||||||
tfl := fl; {(check for dups)}
|
while tfl <> nil do begin
|
||||||
while tfl <> nil do begin
|
if tfl^.name^ = variable^.name^ then begin
|
||||||
if tfl^.name^ = variable^.name^ then begin
|
Error(42);
|
||||||
Error(42);
|
goto 1;
|
||||||
goto 1;
|
end; {if}
|
||||||
end; {if}
|
tfl := tfl^.next;
|
||||||
tfl := tfl^.next;
|
end; {while}
|
||||||
end; {while}
|
|
||||||
end; {if}
|
|
||||||
1: variable^.next := fl;
|
1: variable^.next := fl;
|
||||||
if anonMember <> nil then begin
|
if anonMember <> nil then begin
|
||||||
variable^.anonMemberField := true;
|
variable^.anonMemberField := true;
|
||||||
|
@ -2908,7 +2911,10 @@ var
|
||||||
and ((structsy in fieldDeclSpecifiers.declarationModifiers)
|
and ((structsy in fieldDeclSpecifiers.declarationModifiers)
|
||||||
or (unionsy in fieldDeclSpecifiers.declarationModifiers))
|
or (unionsy in fieldDeclSpecifiers.declarationModifiers))
|
||||||
then begin
|
then begin
|
||||||
variable := NewSymbol(@'~anonymous', tPtr, ident,
|
anonName := pointer(Malloc(sizeof(anonNameString)));
|
||||||
|
anonName^ := concat('~anon', cnvis(anonNumber));
|
||||||
|
anonNumber := anonNumber+1;
|
||||||
|
variable := NewSymbol(anonName, tPtr, ident,
|
||||||
fieldListSpace, defined, false);
|
fieldListSpace, defined, false);
|
||||||
anonMember := true;
|
anonMember := true;
|
||||||
TermHeader; {cannot record anon member in .sym file}
|
TermHeader; {cannot record anon member in .sym file}
|
||||||
|
@ -4758,6 +4764,7 @@ doingForLoopClause1 := false; {not doing a for loop}
|
||||||
fIsNoreturn := false; {not doing a noreturn function}
|
fIsNoreturn := false; {not doing a noreturn function}
|
||||||
compoundLiteralNumber := 1; {no compound literals yet}
|
compoundLiteralNumber := 1; {no compound literals yet}
|
||||||
compoundLiteralToAllocate := nil; {no compound literals needing space yet}
|
compoundLiteralToAllocate := nil; {no compound literals needing space yet}
|
||||||
|
anonNumber := 0; {no anonymous structs/unions yet}
|
||||||
|
|
||||||
{init syntactic classes of tokens}
|
{init syntactic classes of tokens}
|
||||||
{See C17 section 6.7 ff.}
|
{See C17 section 6.7 ff.}
|
||||||
|
|
|
@ -1287,7 +1287,7 @@ var
|
||||||
if ip = nil then ip := defaultStruct^.fieldList;
|
if ip = nil then ip := defaultStruct^.fieldList;
|
||||||
|
|
||||||
while ip <> nil do begin
|
while ip <> nil do begin
|
||||||
if ip^.name^ <> '~anonymous' then
|
if ip^.name^[1] <> '~' then
|
||||||
GenSymbol(ip, none);
|
GenSymbol(ip, none);
|
||||||
ip := ip^.next;
|
ip := ip^.next;
|
||||||
end; {while}
|
end; {while}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user