فهرست منبع

* fix type determining of array of integer constructors

git-svn-id: trunk@4736 -
peter 19 سال پیش
والد
کامیت
75dee03578
3فایلهای تغییر یافته به همراه46 افزوده شده و 6 حذف شده
  1. 1 0
      .gitattributes
  2. 14 6
      compiler/nld.pas
  3. 31 0
      tests/webtbs/tw7446.pp

+ 1 - 0
.gitattributes

@@ -7340,6 +7340,7 @@ tests/webtbs/tw7372.pp svneol=native#text/plain
 tests/webtbs/tw7379.pp svneol=native#text/plain
 tests/webtbs/tw7425.pp svneol=native#text/plain
 tests/webtbs/tw7440.pp svneol=native#text/plain
+tests/webtbs/tw7446.pp svneol=native#text/plain
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 14 - 6
compiler/nld.pas

@@ -653,7 +653,7 @@ implementation
              ccallparanode.create(
                ctypeconvnode.create_internal(right,voidpointertype),
              ccallparanode.create(
-               ctypeconvnode.create_internal(left,voidpointertype), 
+               ctypeconvnode.create_internal(left,voidpointertype),
                nil)));
            result:=ccallnode.createintern('fpc_intf_assign_by_iid',hp);
 
@@ -896,11 +896,19 @@ implementation
                htype:=hp.left.resulttype
               else
                begin
-                 if ((nf_novariaallowed in flags) or (not varia)) and
-                    (not equal_defs(htype.def,hp.left.resulttype.def)) then
-                  begin
-                    varia:=true;
-                  end;
+                 if (not varia) and (not equal_defs(htype.def,hp.left.resulttype.def)) then
+                   begin
+                     { If both are integers we need to take the type that can hold both
+                       defs }
+                     if is_integer(htype.def) and is_integer(hp.left.resulttype.def) then
+                       begin
+                         if is_in_limit(htype.def,hp.left.resulttype.def) then
+                           htype:=hp.left.resulttype;
+                       end
+                     else
+                       if (nf_novariaallowed in flags) then
+                         varia:=true;
+                   end;
                end;
               inc(len);
               hp:=tarrayconstructornode(hp.right);

+ 31 - 0
tests/webtbs/tw7446.pp

@@ -0,0 +1,31 @@
+program openarrayoverload;
+{$ifdef FPC}{$mode objfpc}{$h+}{$INTERFACES CORBA}{$endif}
+{$ifdef mswindows}{$apptype console}{$endif}
+uses
+ {$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
+ sysutils;
+
+type
+ integerarty = array of integer;
+ booleanarty = array of boolean;
+
+function o2d(const values: array of integer): integerarty;
+                                           overload;
+begin
+ result:= nil;
+end;
+
+function o2d(const values: array of boolean): booleanarty;
+                                           overload;
+begin
+ result:= nil;
+end;
+
+var
+ ar1: integerarty;
+
+begin
+ ar1:= o2d([127,2,3]);    // OK
+ ar1:= o2d([128,2,3]);
+  // openarrayoverload.pas(27,8) Error: Can't determine which overloaded function to call
+end.