Kaynağa Gözat

* set maximum alignment of shortstrings to 2 in MacPas mode
(mantis #13187)

git-svn-id: trunk@12745 -

Jonas Maebe 16 yıl önce
ebeveyn
işleme
e58d8d6b92
3 değiştirilmiş dosya ile 20 ekleme ve 1 silme
  1. 1 0
      .gitattributes
  2. 3 1
      compiler/symdef.pas
  3. 16 0
      tests/webtbs/tw13187.pp

+ 1 - 0
.gitattributes

@@ -8759,6 +8759,7 @@ tests/webtbs/tw13019.pp svneol=native#text/plain
 tests/webtbs/tw1310.pp svneol=native#text/plain
 tests/webtbs/tw13133.pp svneol=native#text/plain
 tests/webtbs/tw1318.pp svneol=native#text/plain
+tests/webtbs/tw13187.pp svneol=native#text/plain
 tests/webtbs/tw1323.pp svneol=native#text/plain
 tests/webtbs/tw1327.pp svneol=native#text/plain
 tests/webtbs/tw1331.pp svneol=native#text/plain

+ 3 - 1
compiler/symdef.pas

@@ -1301,8 +1301,10 @@ implementation
             alignment:=size_2_align(savesize);
           st_longstring,
           st_shortstring:
-            if (tf_requires_proper_alignment in target_info.flags) then
               { char to string accesses byte 0 and 1 with one word access }
+            if (tf_requires_proper_alignment in target_info.flags) or
+              { macpas needs an alignment of 2 (MetroWerks compatible) }
+               (m_mac in current_settings.modeswitches) then
               alignment:=size_2_align(2)
             else
               alignment:=size_2_align(1);

+ 16 - 0
tests/webtbs/tw13187.pp

@@ -0,0 +1,16 @@
+{$ifdef FPC}
+{$mode macpas}
+{$endif}
+{$align power}
+program StrSizeTest;
+type
+    StrRec =
+      record
+        s1: string[ 10];
+        s2: string[ 10];
+      end;
+begin
+  writeln( 'SizeOf( StrRec) = ', SizeOf( StrRec));
+  if (sizeof(strrec)<>24) then
+    halt(1);
+end.