Răsfoiți Sursa

* correctly handle result type of string constant nodes for internally created
nodes

git-svn-id: trunk@45231 -

florian 5 ani în urmă
părinte
comite
b6097a0300
3 a modificat fișierele cu 25 adăugiri și 2 ștergeri
  1. 1 0
      .gitattributes
  2. 4 2
      compiler/ncnv.pas
  3. 20 0
      tests/tbs/tb0671.pp

+ 1 - 0
.gitattributes

@@ -13274,6 +13274,7 @@ tests/tbs/tb0668a.pp svneol=native#text/pascal
 tests/tbs/tb0668b.pp svneol=native#text/pascal
 tests/tbs/tb0669.pp svneol=native#text/pascal
 tests/tbs/tb0670.pp svneol=native#text/pascal
+tests/tbs/tb0671.pp svneol=native#text/pascal
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 4 - 2
compiler/ncnv.pas

@@ -2972,12 +2972,14 @@ implementation
                ) then
               begin
                 { output string consts in local ansistring encoding }
-                if is_ansistring(resultdef) and ((tstringdef(resultdef).encoding=0)or(tstringdef(resultdef).encoding=globals.CP_NONE)) then
+                if is_ansistring(resultdef) and
+                  { do not mess with the result type for internally created nodes }
+                  not(nf_internal in flags) and
+                  ((tstringdef(resultdef).encoding=0) or (tstringdef(resultdef).encoding=globals.CP_NONE)) then
                   tstringconstnode(left).changestringtype(getansistringdef)
                 else
                   tstringconstnode(left).changestringtype(resultdef);
                 result:=left;
-                resultdef:=left.resultdef;
                 left:=nil;
                 exit;
               end

+ 20 - 0
tests/tbs/tb0671.pp

@@ -0,0 +1,20 @@
+{$inline on}
+{$mode objfpc}{$H+}
+
+resourcestring
+  rs = 'All files';
+
+function fs: string;inline;
+begin
+  Result:='*';
+end;
+
+
+function f: String;
+begin
+  Result:=rs+' ('+fs+')|'+fs;
+end;
+
+begin
+  writeln(f);
+end.