Explorar el Código

fcl-passrc: resolver: ord(integer)

git-svn-id: trunk@48236 -
Mattias Gaertner hace 4 años
padre
commit
af5a6cd9d2

+ 3 - 3
packages/fcl-passrc/src/pasresolver.pp

@@ -19136,19 +19136,19 @@ begin
     exit(cIncompatible);
     exit(cIncompatible);
   Params:=TParamsExpr(Expr);
   Params:=TParamsExpr(Expr);
 
 
-  // first param: bool, enum or char
+  // first param: bool, integer, enum or char
   Param:=Params.Params[0];
   Param:=Params.Params[0];
   ComputeElement(Param,ParamResolved,[]);
   ComputeElement(Param,ParamResolved,[]);
   Result:=cIncompatible;
   Result:=cIncompatible;
   if rrfReadable in ParamResolved.Flags then
   if rrfReadable in ParamResolved.Flags then
     begin
     begin
-    if ParamResolved.BaseType in (btAllBooleans+btAllChars) then
+    if ParamResolved.BaseType in btArrayRangeTypes then
       Result:=cExact
       Result:=cExact
     else if (ParamResolved.BaseType=btContext) and (ParamResolved.LoTypeEl is TPasEnumType) then
     else if (ParamResolved.BaseType=btContext) and (ParamResolved.LoTypeEl is TPasEnumType) then
       Result:=cExact
       Result:=cExact
     else if ParamResolved.BaseType=btRange then
     else if ParamResolved.BaseType=btRange then
       begin
       begin
-      if ParamResolved.SubType in btAllBooleans+btAllChars then
+      if ParamResolved.SubType in btArrayRangeTypes then
         Result:=cExact
         Result:=cExact
       else if ParamResolved.SubType=btContext then
       else if ParamResolved.SubType=btContext then
         begin
         begin

+ 3 - 1
packages/fcl-passrc/tests/tcresolver.pas

@@ -3359,8 +3359,10 @@ begin
   '  i2: TInt2;',
   '  i2: TInt2;',
   'begin',
   'begin',
   '  i:=i2;',
   '  i:=i2;',
-  '  if i=i2 then ;']);
+  '  if i=i2 then ;',
+  '  i:=ord(i);']);
   ParseProgram;
   ParseProgram;
+  CheckResolverUnexpectedHints;
 end;
 end;
 
 
 procedure TTestResolver.TestIntegerRangeHighLowerLowFail;
 procedure TTestResolver.TestIntegerRangeHighLowerLowFail;