* fix for Mantis #38051: make Chr() a real intrinsics so that it can be used in type declarations as well

+ added test

git-svn-id: trunk@47353 -
This commit is contained in:
svenbarth 2020-11-08 22:23:02 +00:00
parent d5596ef21d
commit c496b609d1
5 changed files with 28 additions and 2 deletions

1
.gitattributes vendored
View File

@ -18522,6 +18522,7 @@ tests/webtbs/tw37969.pp svneol=native#text/pascal
tests/webtbs/tw38012.pp svneol=native#text/pascal
tests/webtbs/tw38022.pp svneol=native#text/pascal
tests/webtbs/tw3805.pp svneol=native#text/plain
tests/webtbs/tw38051.pp svneol=native#text/pascal
tests/webtbs/tw3814.pp svneol=native#text/plain
tests/webtbs/tw3827.pp svneol=native#text/plain
tests/webtbs/tw3829.pp svneol=native#text/plain

View File

@ -290,13 +290,14 @@ implementation
statement_syssym:=new_dispose_statement(false);
end;
in_ord_x :
in_ord_x,
in_chr_byte:
begin
consume(_LKLAMMER);
in_args:=true;
p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER);
p1:=geninlinenode(in_ord_x,false,p1);
p1:=geninlinenode(l,false,p1);
statement_syssym := p1;
end;

View File

@ -70,6 +70,7 @@ implementation
systemunit.insert(csyssym.create('Slice',in_slice_x));
systemunit.insert(csyssym.create('Seg',in_seg_x));
systemunit.insert(csyssym.create('Ord',in_ord_x));
systemunit.insert(csyssym.create('Chr',in_chr_byte));
systemunit.insert(csyssym.create('Pred',in_pred_x));
systemunit.insert(csyssym.create('Succ',in_succ_x));
systemunit.insert(csyssym.create('Exclude',in_exclude_x_y));

View File

@ -1293,7 +1293,9 @@ Function HexStr(Val:Pointer):shortstring;
{$endif CPUI8086}
{ Char functions }
{$ifdef VER3_2}
Function Chr(b : byte) : Char; [INTERNPROC: fpc_in_chr_byte];
{$endif VER3_2}
Function UpCase(c:Char):Char;
Function LowerCase(c:Char):Char; overload;
function Pos(const substr : shortstring;c:char; Offset: Sizeint = 1): SizeInt;

21
tests/webtbs/tw38051.pp Normal file
View File

@ -0,0 +1,21 @@
{ %NORUN }
program tw38051;
const cChr = chr(12); { Ok }
type Tcha = ord(3)..ord(12); { Ok }
type Tchz = 0000003..0000012; { Ok }
type Tcho = char(3)..char(12);{ Ok }
type Tchr = chr(3)..chr(12); { Error: Identifier not found "chr" }
type TArrChr = array [chr(3)..chr(12)] of char; { Ok }
var cz : 0000003..0000012; { Ok }
var ch : chr(3)..chr(12); { Error: Identifier not found "chr" }
var c : char;
begin
c:=chr(12); { Ok }
end.