Browse Source

* test for wrong first match of operator overloading

git-svn-id: trunk@7703 -
peter 18 năm trước cách đây
mục cha
commit
65a721de66
2 tập tin đã thay đổi với 36 bổ sung0 xóa
  1. 1 0
      .gitattributes
  2. 35 0
      tests/test/toperator6.pp

+ 1 - 0
.gitattributes

@@ -6894,6 +6894,7 @@ tests/test/toperator2.pp svneol=native#text/plain
 tests/test/toperator3.pp svneol=native#text/plain
 tests/test/toperator4.pp svneol=native#text/plain
 tests/test/toperator5.pp svneol=native#text/plain
+tests/test/toperator6.pp svneol=native#text/plain
 tests/test/tover1.pp svneol=native#text/plain
 tests/test/tover2.pp svneol=native#text/plain
 tests/test/tpackrec.pp svneol=native#text/plain

+ 35 - 0
tests/test/toperator6.pp

@@ -0,0 +1,35 @@
+{$mode objfpc}
+{$R+}
+
+type  Tconstexprint=record
+        overflow:boolean;
+        case signed:boolean of
+          false:
+            (uvalue:qword);
+          true:
+            (svalue:int64);
+      end;
+
+operator := (const u:qword):Tconstexprint;
+begin
+  result.overflow:=false;
+  result.signed:=false;
+  result.uvalue:=u;
+end;
+
+operator := (const s:int64):Tconstexprint;
+begin
+  result.overflow:=false;
+  result.signed:=true;
+  result.svalue:=s;
+end;
+
+
+var
+  value : tconstexprint;
+begin
+  // Here it should choose the int64 code instead of qword
+  value:=-128;
+  // Here it should choose the qword
+  value:=high(int64)+100;
+end.