Переглянути джерело

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 -
svenbarth 11 роки тому
батько
коміт
a08e8ff982
3 змінених файлів з 28 додано та 2 видалено
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/ninl.pas
  3. 25 0
      tests/webtbs/tw25929.pp

+ 1 - 0
.gitattributes

@@ -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

+ 2 - 2
compiler/ninl.pas

@@ -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 - 0
tests/webtbs/tw25929.pp

@@ -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.
+