Avoid spurious undefined variable errors for functions returning structs/unions.

When the lint check for undefined variables was enabled, a "lint: unused variable: @struct" would be produced for any function returning a struct or union, due to the special static variable that is created to hold the return value. That spurious lint message is now suppressed.
This commit is contained in:
Stephen Heumann 2023-04-06 18:52:45 -05:00
parent 20f9170343
commit e5c7aebb3f
1 changed files with 7 additions and 5 deletions

View File

@ -489,11 +489,13 @@ if not tPtr^.isEmpty or not tPtr^.noStatics then
if not (ip^.itype^.kind in [functionType,enumConst]) then
if ip^.storage = private then
if copy(ip^.name^,1,staticNumLen) = tPtr^.staticNum then
begin
new(nameStr);
nameStr^ := copy(ip^.name^, staticNumLen+1, maxint);
ErrorWithExtraString(185, nameStr);
end; {if}
if not (ip^.name^[staticNumLen+1] in ['~','@']) then
begin
new(nameStr);
nameStr^ :=
copy(ip^.name^, staticNumLen+1, maxint);
ErrorWithExtraString(185, nameStr);
end; {if}
ip := ip^.next;
end; {while}
end; {if}