瀏覽代碼

* 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 -

svenbarth 4 年之前
父節點
當前提交
c496b609d1
共有 5 個文件被更改,包括 28 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 3 2
      compiler/pexpr.pas
  3. 1 0
      compiler/psystem.pas
  4. 2 0
      rtl/inc/systemh.inc
  5. 21 0
      tests/webtbs/tw38051.pp

+ 1 - 0
.gitattributes

@@ -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

+ 3 - 2
compiler/pexpr.pas

@@ -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;
 

+ 1 - 0
compiler/psystem.pas

@@ -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));

+ 2 - 0
rtl/inc/systemh.inc

@@ -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 - 0
tests/webtbs/tw38051.pp

@@ -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.