Ver Fonte

* also fix rtti for named enumerations
* updated test program to test both named and unnamed enumerations

git-svn-id: trunk@10741 -

tom_at_work há 17 anos atrás
pai
commit
553b524c0a
2 ficheiros alterados com 16 adições e 2 exclusões
  1. 1 0
      compiler/ncgrtti.pas
  2. 15 2
      tests/webtbs/tw10033.pp

+ 1 - 0
compiler/ncgrtti.pas

@@ -393,6 +393,7 @@ implementation
            hp : tenumsym;
         begin
           current_asmdata.asmlists[al_rtti].concat(Tai_const.Create_8bit(tkEnumeration));
+          current_asmdata.asmlists[al_rtti].concat(Cai_align.Create(cshortstringtype.alignment));	  
           write_rtti_name(def);
           if (tf_requires_proper_alignment in target_info.flags) then
             current_asmdata.asmlists[al_rtti].concat(Cai_align.Create(sizeof(TConstPtrUInt)));

+ 15 - 2
tests/webtbs/tw10033.pp

@@ -2,13 +2,17 @@
 // writing and reading of rtti for enums, both "dense" and 
 // "sparse" enumerations (different rtti is generated and 
 // different code used for generating and reading)
-{$mode objfpc}
 type
+  // "dense" unnamed enumeration
+  Txx = set of (_one, _two, _three);
+  // "sparse" unnamed enumeration
+  Tyy = set of (_zero := 0, _ten := 10, _twenty := 20);
+
   // "dense" enumeration
   Tx = (one,two,three);
   Txxx = set of Tx;
   // "sparse" enumeration
-  Ty =(zero := 0, ten := 10, twenty := 20);
+  Ty = (zero := 0, ten := 10, twenty := 20);
   Tyyy = set of Ty;
 
 procedure error(number : longint);
@@ -21,8 +25,17 @@ var
   x : txxx;
   y : tyyy;
   err : word;
+  
+  _x : txx;
+  _y : tyy;
 
 begin
+  writeln(low(_x));
+  writeln(high(_x));
+
+  writeln(low(_y));
+  writeln(high(_y));
+
   writeln(low(x));
   writeln(high(x));