default value: fix issue with inlining

Ensure the mangled name is always the same

Resolves #40404
This commit is contained in:
Jonas Maebe 2023-08-20 22:06:13 +02:00
parent 6ab91262b2
commit 1be7416816
3 changed files with 30 additions and 3 deletions

View File

@ -475,14 +475,15 @@ implementation
begin
{ no valid default variable found, so create it }
srsym:=cstaticvarsym.create(defaultname,vs_const,def,[]);
srsymtable.insertsym(srsym);
cnodeutils.insertbssdata(tstaticvarsym(srsym));
{ mark the staticvarsym as typedconst }
include(tabstractvarsym(srsym).varoptions,vo_is_typed_const);
include(tabstractvarsym(srsym).varoptions,vo_is_default_var);
{ The variable has a value assigned }
tabstractvarsym(srsym).varstate:=vs_initialised;
srsymtable.insertsym(srsym);
cnodeutils.insertbssdata(tstaticvarsym(srsym));
end;
result:=cloadnode.create(srsym,srsymtable);
end

5
tests/webtbs/tw40395c.pp Normal file
View File

@ -0,0 +1,5 @@
uses uw40395c;
begin
test;
end.

21
tests/webtbs/uw40395c.pp Normal file
View File

@ -0,0 +1,21 @@
unit uw40395c;
interface
type
trec = record
a,b,c,d: longint;
end;
procedure test; inline;
implementation
procedure test; inline;
var
r: trec;
begin
r:=default(trec);
end;
end.