Fix for Mantis #25929

* ninl.pas, tinlinenode.handle_default.getdefaultvarsym:
    prefix the default variable's name with a "$zero" instead of a "zero" and use only the string from the second character on for comparisons so that findwithhash() and checkduplicates() generate consistent results

+ added test

git-svn-id: trunk@27320 -
This commit is contained in:
svenbarth 2014-03-28 14:45:18 +00:00
parent e003e1773c
commit a08e8ff982
3 changed files with 28 additions and 2 deletions

1
.gitattributes vendored
View File

@ -13862,6 +13862,7 @@ tests/webtbs/tw25869.pp svneol=native#text/plain
tests/webtbs/tw2588.pp svneol=native#text/plain
tests/webtbs/tw2589.pp svneol=native#text/plain
tests/webtbs/tw25895.pp svneol=native#text/pascal
tests/webtbs/tw25929.pp svneol=native#text/pascal
tests/webtbs/tw2594.pp svneol=native#text/plain
tests/webtbs/tw2595.pp svneol=native#text/plain
tests/webtbs/tw2602.pp svneol=native#text/plain

View File

@ -392,8 +392,8 @@ implementation
not (def.typ in [arraydef,recorddef,variantdef,objectdef,procvardef]) or
((def.typ=objectdef) and not is_object(def)) then
internalerror(201202101);
defaultname:=make_mangledname('zero',def.owner,def.typesym.Name);
hashedid.id:=defaultname;
defaultname:=make_mangledname('$zero',def.owner,def.typesym.Name);
hashedid.id:=copy(defaultname,2,255);
{ the default sym is always part of the current procedure/function }
srsymtable:=current_procinfo.procdef.localst;
srsym:=tsym(srsymtable.findwithhash(hashedid));

25
tests/webtbs/tw25929.pp Normal file
View File

@ -0,0 +1,25 @@
{ %NORUN }
program tw25929;
{$MODE DELPHI}
type
TR<T> = record
end;
TA<T> = class
procedure Foo;
end;
procedure TA<T>.Foo;
var
r: TR<T>;
begin
r := Default(TR<T>);
r := Default(TR<T>); // Error: Duplicate identifier "zero_$P$PLC03_$$_TR$1"
end;
begin
end.