Forráskód Böngészése

default value: fix issue with inlining

Ensure the mangled name is always the same

Resolves #40404
Jonas Maebe 1 éve
szülő
commit
1be7416816
3 módosított fájl, 30 hozzáadás és 3 törlés
  1. 4 3
      compiler/ninl.pas
  2. 5 0
      tests/webtbs/tw40395c.pp
  3. 21 0
      tests/webtbs/uw40395c.pp

+ 4 - 3
compiler/ninl.pas

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

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

+ 21 - 0
tests/webtbs/uw40395c.pp

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