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

* change the type of the -gt uninitialised result of ansistring functions to
rawbytestring so the compiler does not try to convert it to the declared
string type of the function result, as this may not be available
(mantis #32510)

git-svn-id: trunk@37889 -

Jonas Maebe 7 роки тому
батько
коміт
c0b0fa9c0b
3 змінених файлів з 33 додано та 6 видалено
  1. 1 0
      .gitattributes
  2. 14 6
      compiler/ngenutil.pas
  3. 18 0
      tests/webtbs/tw32510.pp

+ 1 - 0
.gitattributes

@@ -15913,6 +15913,7 @@ tests/webtbs/tw3235.pp svneol=native#text/plain
 tests/webtbs/tw3235a.pp svneol=native#text/plain
 tests/webtbs/tw3241a.pp svneol=native#text/plain
 tests/webtbs/tw32474.pp svneol=native#text/pascal
+tests/webtbs/tw32510.pp svneol=native#text/plain
 tests/webtbs/tw3252.pp svneol=native#text/plain
 tests/webtbs/tw3255.pp svneol=native#text/plain
 tests/webtbs/tw3257.pp svneol=native#text/plain

+ 14 - 6
compiler/ngenutil.pas

@@ -676,6 +676,7 @@ implementation
     var
       size: asizeint;
       trashintval: int64;
+      stringres: tstringconstnode;
     begin
       if trashable_sym(p) then
         begin
@@ -695,12 +696,19 @@ implementation
           if is_managed_type(p.vardef) then
             begin
               if is_string(p.vardef) then
-                trash_small(stat,trashn,
-                  cstringconstnode.createstr(
-                    'uninitialized function result in '+
-                    tprocdef(p.owner.defowner).customprocname([pno_proctypeoption, pno_paranames,pno_ownername, pno_noclassmarker])
-                  )
-                )
+                begin
+                  stringres:=
+                    cstringconstnode.createstr(
+                      'uninitialized function result in '+
+                      tprocdef(p.owner.defowner).customprocname([pno_proctypeoption, pno_paranames,pno_ownername, pno_noclassmarker])
+                    );
+                  { prevent attempts to convert the string to the specified
+                    code page at compile time, as it may not be available (and
+                    it does not matter) }
+                  if is_ansistring(p.vardef) then
+                    stringres.changestringtype(search_system_type('RAWBYTESTRING').typedef);
+                  trash_small(stat,trashn,stringres);
+                end
               else
                 internalerror(2016030601);
             end

+ 18 - 0
tests/webtbs/tw32510.pp

@@ -0,0 +1,18 @@
+{ %norun }
+
+unit tw32510;
+interface
+
+type
+  RawUnicode = type AnsiString(1200);
+
+function AnsiToRawUnicode(const AnsiText: RawByteString): RawUnicode;
+
+implementation
+
+function AnsiToRawUnicode(const AnsiText: RawByteString): RawUnicode;
+begin
+end;
+
+initialization
+end.