Browse Source

* If object has VMT, properly align whole object instance if target CPU requires alignment. It fixes usage of static object instances created as var or const on CPUs which require alignment.
* Partially reverted Micha's fix in revs 10544,10546,10548, because it is not needed anymore.

git-svn-id: trunk@10648 -

yury 17 years ago
parent
commit
348e30958e
2 changed files with 5 additions and 4 deletions
  1. 0 3
      compiler/ptconst.pas
  2. 5 1
      compiler/symdef.pas

+ 0 - 3
compiler/ptconst.pas

@@ -1174,7 +1174,6 @@ implementation
           obj    : tobjectdef;
           srsym  : tsym;
           st     : tsymtable;
-          objst  : tobjectsymtable;
           curroffset : aint;
           s,sorg : TIDString;
           vmtwritten : boolean;
@@ -1250,8 +1249,6 @@ implementation
                        (oo_has_vmt in def.objectoptions) and
                        (def.vmt_offset<fieldoffset) then
                       begin
-                        objst:=tobjectsymtable(def.symtable);
-                        objst.alignrecord(def.vmt_offset,sizeof(TConstPtrUInt));
                         for i:=1 to def.vmt_offset-curroffset do
                           list.concat(tai_const.create_8bit(0));
                         list.concat(tai_const.createname(def.vmt_mangledname,0));

+ 5 - 1
compiler/symdef.pas

@@ -3922,7 +3922,11 @@ implementation
                  tObjectSymtable(symtable).fieldalignment);
 
              if (tf_requires_proper_alignment in target_info.flags) then
-               tObjectSymtable(symtable).datasize:=align(tObjectSymtable(symtable).datasize,sizeof(pint));
+               begin
+                 { Align VMT pointer and whole object instance if target CPU requires alignment. }
+                 tObjectSymtable(symtable).datasize:=align(tObjectSymtable(symtable).datasize,sizeof(pint));
+                 tObjectSymtable(symtable).alignrecord(tObjectSymtable(symtable).datasize,sizeof(pint));
+               end;
 
              vmt_offset:=tObjectSymtable(symtable).datasize;
              tObjectSymtable(symtable).datasize:=