Bläddra i källkod

compiler: allow type conversions for ordinal types inside type declarations e.g inside enumerations like: Byte(0)..Byte(15)

git-svn-id: trunk@19328 -
paul 14 år sedan
förälder
incheckning
33a67704ac
3 ändrade filer med 17 tillägg och 1 borttagningar
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/pexpr.pas
  3. 12 0
      tests/test/ttypeconvtypes.pp

+ 1 - 0
.gitattributes

@@ -10552,6 +10552,7 @@ tests/test/tsubdecl.pp svneol=native#text/plain
 tests/test/tsymlibrary1.pp svneol=native#text/pascal
 tests/test/ttpara1.pp svneol=native#text/plain
 tests/test/ttpara2.pp svneol=native#text/plain
+tests/test/ttypeconvtypes.pp svneol=native#text/pascal
 tests/test/ttypedarray1.pp svneol=native#text/pascal
 tests/test/ttypedrecord1.pp svneol=native#text/plain
 tests/test/ttypedrecord2.pp svneol=native#text/plain

+ 4 - 1
compiler/pexpr.pas

@@ -1496,7 +1496,10 @@ implementation
                           (token=_LT) and
                           (m_delphi in current_settings.modeswitches) then
                           generate_specialization(hdef,false,'');
-                       if not typeonly and try_to_consume(_LKLAMMER) then
+                       { allow Ordinal(Value) for type declarations since it
+                         can be an enummeration declaration or a set lke:
+                         (OrdinalType(const1)..OrdinalType(const2) }
+                       if (not typeonly or is_ordinal(hdef))and try_to_consume(_LKLAMMER) then
                         begin
                           p1:=comp_expr(true,false);
                           consume(_RKLAMMER);

+ 12 - 0
tests/test/ttypeconvtypes.pp

@@ -0,0 +1,12 @@
+{%norun}
+program ttypeconvtypes;
+
+// check that type conversions work in type declarations
+// also check that codepage ansistring declaration also works
+
+type
+  t866 = type AnsiString(866);
+  tbytes = byte(0)..byte(15);
+  tchars = ansichar(tbytes(0))..ansichar(tbytes(15));
+begin
+end.