Bladeren bron

* workaround for default property constant value limitations

git-svn-id: trunk@10575 -
Jonas Maebe 17 jaren geleden
bovenliggende
commit
7e4750ac50
3 gewijzigde bestanden met toevoegingen van 24 en 2 verwijderingen
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/pdecvar.pas
  3. 21 0
      tests/tbs/tb0547.pp

+ 1 - 0
.gitattributes

@@ -6830,6 +6830,7 @@ tests/tbs/tb0543.pp svneol=native#text/plain
 tests/tbs/tb0544.pp svneol=native#text/plain
 tests/tbs/tb0545.pp svneol=native#text/plain
 tests/tbs/tb0546.pp svneol=native#text/plain
+tests/tbs/tb0547.pp svneol=native#text/plain
 tests/tbs/tb205.pp svneol=native#text/plain
 tests/tbs/ub0060.pp svneol=native#text/plain
 tests/tbs/ub0069.pp svneol=native#text/plain

+ 2 - 2
compiler/pdecvar.pas

@@ -605,8 +605,8 @@ implementation
                     setconstn :
                       p.default:=plongint(tsetconstnode(pt).value_set)^;
                     ordconstn :
-                      if (Tordconstnode(pt).value<int64(low(p.default))) or
-                         (Tordconstnode(pt).value>int64(high(p.default))) then
+                      if (Tordconstnode(pt).value<int64(low(longint))) or
+                         (Tordconstnode(pt).value>int64(high(cardinal))) then
                         message(parser_e_range_check_error)
                       else
                         p.default:=longint(tordconstnode(pt).value.svalue);

+ 21 - 0
tests/tbs/tb0547.pp

@@ -0,0 +1,21 @@
+{ %norun }
+
+program rangeerror;
+{$ifdef FPC}{$mode objfpc}{$h+}{$endif}
+{$ifdef mswindows}{$apptype console}{$endif}
+uses
+{$ifdef FPC}{$ifdef linux}cthreads,{$endif}{$endif}
+sysutils;
+type
+colorty = type longword;
+const
+cl_mapped = colorty($90000000);
+type
+ttestclass = class
+ private
+  fcolor: colorty;
+ published
+  property color: colorty read fcolor write fcolor default cl_mapped; //<<--
+end; 
+begin
+end.