Browse Source

* fix wrong constant temp handling, introduced in r24953, resolves #24915

git-svn-id: trunk@25684 -
florian 12 years ago
parent
commit
f95b225157
3 changed files with 21 additions and 15 deletions
  1. 1 0
      .gitattributes
  2. 1 15
      compiler/ncal.pas
  3. 19 0
      tests/webtbs/tw24915.pp

+ 1 - 0
.gitattributes

@@ -13588,6 +13588,7 @@ tests/webtbs/tw24863.pp svneol=native#text/plain
 tests/webtbs/tw24865.pp svneol=native#text/pascal
 tests/webtbs/tw24865.pp svneol=native#text/pascal
 tests/webtbs/tw24867.pp svneol=native#text/pascal
 tests/webtbs/tw24867.pp svneol=native#text/pascal
 tests/webtbs/tw24871.pp svneol=native#text/pascal
 tests/webtbs/tw24871.pp svneol=native#text/pascal
+tests/webtbs/tw24915.pp svneol=native#text/pascal
 tests/webtbs/tw2492.pp svneol=native#text/plain
 tests/webtbs/tw2492.pp svneol=native#text/plain
 tests/webtbs/tw2494.pp svneol=native#text/plain
 tests/webtbs/tw2494.pp svneol=native#text/plain
 tests/webtbs/tw24953.pp svneol=native#text/pascal
 tests/webtbs/tw24953.pp svneol=native#text/pascal

+ 1 - 15
compiler/ncal.pas

@@ -3814,7 +3814,7 @@ implementation
                 if para.parasym.varspez=vs_const then
                 if para.parasym.varspez=vs_const then
                   pushconstaddr:=paramanager.push_addr_param(vs_const,para.parasym.vardef,procdefinition.proccalloption);
                   pushconstaddr:=paramanager.push_addr_param(vs_const,para.parasym.vardef,procdefinition.proccalloption);
                 { check if we have to create a temp, assign the parameter's }
                 { check if we have to create a temp, assign the parameter's }
-                { contents to that temp and then substitute the paramter    }
+                { contents to that temp and then substitute the parameter   }
                 { with the temp everywhere in the function                  }
                 { with the temp everywhere in the function                  }
                 if
                 if
                   ((tparavarsym(para.parasym).varregable in [vr_none,vr_addr]) and
                   ((tparavarsym(para.parasym).varregable in [vr_none,vr_addr]) and
@@ -3904,20 +3904,6 @@ implementation
                       begin
                       begin
                         tempnode := ctempcreatenode.create(para.parasym.vardef,para.parasym.vardef.size,
                         tempnode := ctempcreatenode.create(para.parasym.vardef,para.parasym.vardef.size,
                           tt_persistent,tparavarsym(para.parasym).is_regvar(false));
                           tt_persistent,tparavarsym(para.parasym).is_regvar(false));
-
-                        { inherit const }
-                        if tabstractvarsym(para.parasym).varspez=vs_const then
-                          begin
-                            include(tempnode.tempinfo^.flags,ti_const);
-
-                            { apply less strict rules for the temp. to be a register than
-                              ttempcreatenode does
-
-                              this way, dyn. array, ansistrings etc. can be put into registers as well }
-                            if tparavarsym(para.parasym).is_regvar(false) then
-                              include(tempnode.tempinfo^.flags,ti_may_be_in_reg);
-                          end;
-
                         addstatement(inlineinitstatement,tempnode);
                         addstatement(inlineinitstatement,tempnode);
 
 
                         if localvartrashing <> -1 then
                         if localvartrashing <> -1 then

+ 19 - 0
tests/webtbs/tw24915.pp

@@ -0,0 +1,19 @@
+program err;
+
+{$mode objfpc}{$H+}
+
+uses SysUtils;
+
+function test(const a, b: string): string; inline;
+begin
+  result:=b;
+end;
+
+const path: string = 'C:\123456789012345678901234567890\test.txt';
+var t: string;
+
+begin
+  t:=test(ExtractFilePath(path), ExtractFilePath(path));
+  writeln(stringcodepage(path));
+  writeln('Path: '+t);
+end.