* synchronized with trunk

git-svn-id: branches/unicodekvm@48499 -
This commit is contained in:
nickysn 2021-02-02 04:03:00 +00:00
commit 4119d1e05f
9 changed files with 111 additions and 41 deletions

View File

@ -18763,53 +18763,66 @@ function TPasResolver.BI_InExclude_OnGetCallCompatibility(
// check params of built in proc 'include' // check params of built in proc 'include'
var var
Params: TParamsExpr; Params: TParamsExpr;
Param: TPasExpr; Param0, Param1: TPasExpr;
ParamResolved: TPasResolverResult; Param0Resolved, Param1Resolved: TPasResolverResult;
EnumType: TPasEnumType; EnumType: TPasEnumType;
C: TClass; C: TClass;
LoTypeEl: TPasType;
RgType: TPasRangeType;
begin begin
if not CheckBuiltInMinParamCount(Proc,Expr,2,RaiseOnError) then if not CheckBuiltInMinParamCount(Proc,Expr,2,RaiseOnError) then
exit(cIncompatible); exit(cIncompatible);
Params:=TParamsExpr(Expr); Params:=TParamsExpr(Expr);
// first param: set variable // first Param0: set variable
// todo set of int, set of char, set of bool // todo set of int, set of char, set of bool
Param:=Params.Params[0]; Param0:=Params.Params[0];
ComputeElement(Param,ParamResolved,[rcNoImplicitProc]); ComputeElement(Param0,Param0Resolved,[rcNoImplicitProc]);
Param1:=Params.Params[1];
ComputeElement(Param1,Param1Resolved,[]);
EnumType:=nil; EnumType:=nil;
if ([rrfReadable,rrfWritable]*ParamResolved.Flags=[rrfReadable,rrfWritable]) RgType:=nil;
and (ParamResolved.IdentEl<>nil) then if ([rrfReadable,rrfWritable]*Param0Resolved.Flags=[rrfReadable,rrfWritable])
and (Param0Resolved.IdentEl<>nil) then
begin begin
C:=ParamResolved.IdentEl.ClassType; C:=Param0Resolved.IdentEl.ClassType;
if (C.InheritsFrom(TPasVariable) if (C.InheritsFrom(TPasVariable)
or (C=TPasArgument) or (C=TPasArgument)
or (C=TPasResultElement)) then or (C=TPasResultElement)) then
begin begin
if (ParamResolved.BaseType=btSet) if Param0Resolved.BaseType=btSet then
and (ParamResolved.LoTypeEl is TPasEnumType) then
EnumType:=TPasEnumType(ParamResolved.LoTypeEl);
end;
end;
if EnumType=nil then
begin begin
{$IFDEF VerbosePasResolver} LoTypeEl:=Param0Resolved.LoTypeEl;
writeln('TPasResolver.OnGetCallCompatibility_InExclude ',GetResolverResultDbg(ParamResolved)); if LoTypeEl.ClassType=TPasEnumType then
{$ENDIF} begin
exit(CheckRaiseTypeArgNo(20170216152301,1,Param,ParamResolved, EnumType:=TPasEnumType(LoTypeEl);
'variable of set of enumtype',RaiseOnError)); if (not (rrfReadable in Param0Resolved.Flags))
end; or (Param0Resolved.LoTypeEl<>EnumType) then
// second param: enum
Param:=Params.Params[1];
ComputeElement(Param,ParamResolved,[]);
if (not (rrfReadable in ParamResolved.Flags))
or (ParamResolved.LoTypeEl<>EnumType) then
begin begin
if RaiseOnError then if RaiseOnError then
RaiseIncompatibleType(20170216152302,nIncompatibleTypeArgNo, RaiseIncompatibleType(20210201225926,nIncompatibleTypeArgNo,
['2'],ParamResolved.LoTypeEl,EnumType,Param); ['2'],Param0Resolved.LoTypeEl,EnumType,Param0);
exit(cIncompatible); exit(cIncompatible);
end; end;
end
else if LoTypeEl.ClassType=TPasRangeType then
begin
RgType:=TPasRangeType(LoTypeEl);
ComputeElement(RgType.RangeExpr.left,Param0Resolved,[]);
Result:=CheckAssignResCompatibility(Param0Resolved,Param1Resolved,Param1,RaiseOnError);
end;
end;
end;
end;
if (EnumType=nil) and (RgType=nil) then
begin
{$IFDEF VerbosePasResolver}
writeln('TPasResolver.OnGetCallCompatibility_InExclude ',GetResolverResultDbg(Param0Resolved));
{$ENDIF}
exit(CheckRaiseTypeArgNo(20170216152301,1,Param0,Param0Resolved,
'variable of set of enumtype',RaiseOnError));
end;
Result:=CheckBuiltInMaxParamCount(Proc,Params,2,RaiseOnError); Result:=CheckBuiltInMaxParamCount(Proc,Params,2,RaiseOnError);
end; end;

View File

@ -3360,7 +3360,8 @@ begin
'begin', 'begin',
' i:=i2;', ' i:=i2;',
' if i=i2 then ;', ' if i=i2 then ;',
' i:=ord(i);']); ' i:=ord(i);',
'']);
ParseProgram; ParseProgram;
CheckResolverUnexpectedHints; CheckResolverUnexpectedHints;
end; end;
@ -4232,7 +4233,9 @@ begin
' s:= {#s3_set}[3..4];', ' s:= {#s3_set}[3..4];',
' s:= {#s4_set}[Three];', ' s:= {#s4_set}[Three];',
' if 3 in a then ;', ' if 3 in a then ;',
' s:=c;']); ' s:=c;',
' Include(s,3);',
'']);
ParseProgram; ParseProgram;
CheckParamsExpr_pkSet_Markers; CheckParamsExpr_pkSet_Markers;
CheckResolverUnexpectedHints; CheckResolverUnexpectedHints;

View File

@ -389,6 +389,7 @@ type
Procedure TestSet_Property; Procedure TestSet_Property;
Procedure TestSet_EnumConst; Procedure TestSet_EnumConst;
Procedure TestSet_IntConst; Procedure TestSet_IntConst;
Procedure TestSet_IntRange;
Procedure TestSet_AnonymousEnumType; Procedure TestSet_AnonymousEnumType;
Procedure TestSet_AnonymousEnumTypeChar; // ToDo Procedure TestSet_AnonymousEnumTypeChar; // ToDo
Procedure TestSet_ConstEnum; Procedure TestSet_ConstEnum;
@ -6420,6 +6421,44 @@ begin
''])); '']));
end; end;
procedure TTestModule.TestSet_IntRange;
begin
StartProgram(false);
Add([
'type',
' TRange = 1..3;',
' TEnums = set of TRange;',
'const',
' Orange = 2;',
'var',
' Enum: byte;',
' Enums: TEnums;',
'begin',
' Enums:=[];',
' Enums:=[1];',
' Enums:=[2..3];',
' Include(enums,orange);',
' Exclude(enums,orange);',
' if orange in enums then;',
' if orange in [orange,1] then;']);
ConvertProgram;
CheckSource('TestSet_IntRange',
LinesToStr([ // statements
'this.Orange = 2;',
'this.Enum = 0;',
'this.Enums = {};',
'']),
LinesToStr([
'$mod.Enums = {};',
'$mod.Enums = rtl.createSet(1);',
'$mod.Enums = rtl.createSet(null, 2, 3);',
'$mod.Enums = rtl.includeSet($mod.Enums, 2);',
'$mod.Enums = rtl.excludeSet($mod.Enums, 2);',
'if (2 in $mod.Enums) ;',
'if (2 in rtl.createSet(2, 1)) ;',
'']));
end;
procedure TTestModule.TestSet_AnonymousEnumType; procedure TTestModule.TestSet_AnonymousEnumType;
begin begin
StartProgram(false); StartProgram(false);

View File

@ -555,8 +555,10 @@ Type
tkernel_timespecs = array[0..1] of kernel_timespec; tkernel_timespecs = array[0..1] of kernel_timespec;
{$ifndef android}
Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF} Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
Function futimens(fd: cint; const times:tkernel_timespecs):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'futimens'; {$ENDIF} Function futimens(fd: cint; const times:tkernel_timespecs):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'futimens'; {$ENDIF}
{$endif android}
implementation implementation
@ -875,6 +877,7 @@ end;
{$endif} {$endif}
{$ifndef android}
Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint; Function utimensat(dfd: cint; path:pchar;const times:tkernel_timespecs;flags:cint):cint;
var var
tsa: Array[0..1] of timespec; tsa: Array[0..1] of timespec;
@ -913,6 +916,7 @@ begin
futimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@times),0); futimens:=do_syscall(syscall_nr_utimensat,fd,TSysParam(nil),TSysParam(@times),0);
{$endif sizeof(clong)<=4} {$endif sizeof(clong)<=4}
end; end;
{$endif android}
end. end.

View File

@ -11,7 +11,7 @@ uses
type type
TMyVar = packed record TMyVar = packed record
VType: TVarType; VType: TVarType;
Dummy1: array[0..Pred(SizeOf(Pointer) - 2)] of Byte; Dummy1: array[0..2] of Word;
Dummy2, Dummy2,
Dummy3: Pointer; Dummy3: Pointer;
procedure Init; procedure Init;

View File

@ -1,5 +1,8 @@
unit dw_chm; unit dw_chm;
{$mode objfpc}
{$h+}
interface interface
uses Classes, DOM, uses Classes, DOM,

View File

@ -1473,6 +1473,13 @@ begin
if aEL.ExternalName<>'' then if aEL.ExternalName<>'' then
aLine:=aLine+' external name '''+ael.ExternalName+''''; aLine:=aLine+' external name '''+ael.ExternalName+'''';
if Assigned(aEL.AncestorType) then if Assigned(aEL.AncestorType) then
if (aEL.AncestorType is TPasSpecializeType) then
begin
aLine:=aLine+'(specialize ';
aLine:=aLine+ TPasSpecializeType(aEL.AncestorType).DestType.Name;
aLine:=aLine+ '<,>)';
end
else
begin begin
aLine:=aLine+' ('+ael.AncestorType.Name; aLine:=aLine+' ('+ael.AncestorType.Name;
if Assigned(ael.Interfaces) and (aEl.Interfaces.Count>0) then if Assigned(ael.Interfaces) and (aEl.Interfaces.Count>0) then

View File

@ -1621,7 +1621,7 @@ end;
procedure TFPDocWriter.OutputResults(); procedure TFPDocWriter.OutputResults();
begin begin
DoLog('Documentation process finished.'); DoLog('Package: %s - Documentation process finished.', [FPackage.Name]);
end; end;
function TFPDocWriter.ConvertExtShort(AContext: TPasElement; function TFPDocWriter.ConvertExtShort(AContext: TPasElement;

View File

@ -14,7 +14,8 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
} }
{$mode objfpc}
{$h+}
program FPDoc; program FPDoc;
uses uses