Jelajahi Sumber

* Fixed error "Incompatible type for arg no. X: Got "Array Of Char", expected "Array Of PChar"" when passing values like ['1','2','3'] for "array of PChar" parameter.
+ Test added.

git-svn-id: trunk@6495 -

yury 18 tahun lalu
induk
melakukan
48e46f1c2e
3 mengubah file dengan 24 tambahan dan 1 penghapusan
  1. 1 0
      .gitattributes
  2. 1 1
      compiler/defcmp.pas
  3. 22 0
      tests/tbs/tb0529.pp

+ 1 - 0
.gitattributes

@@ -6221,6 +6221,7 @@ tests/tbs/tb0525.pp svneol=native#text/plain
 tests/tbs/tb0526.pp -text
 tests/tbs/tb0527.pp svneol=native#text/plain
 tests/tbs/tb0528.pp svneol=native#text/x-pascal
+tests/tbs/tb0529.pp -text
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain
 tests/tbs/ub0119.pp svneol=native#text/plain

+ 1 - 1
compiler/defcmp.pas

@@ -877,7 +877,7 @@ implementation
                  orddef :
                    begin
                      { char constant to zero terminated string constant }
-                     if (fromtreetype=ordconstn) then
+                     if (fromtreetype in [ordconstn,arrayconstructorn]) then
                       begin
                         if (is_char(def_from) or is_widechar(def_from)) and
                            (is_pchar(def_to) or is_pwidechar(def_to)) then

+ 22 - 0
tests/tbs/tb0529.pp

@@ -0,0 +1,22 @@
+{ It tests conversion from "array of char" to "array of PChar" }
+
+function DoTest(params: array of PChar): string;
+var
+  i: integer;
+  res: string;
+begin
+  res:='';
+  for i:=Low(params) to High(params) do
+    res:=res + params[i];
+  DoTest:=res;
+end;
+
+var
+  s: string;
+begin
+  s:=DoTest(['1', '2', '3']);
+  if s <> '123' then begin
+    writeln('Test failed. S=', s);
+    Halt(1);
+  end;
+end.