Browse Source

+ $A similiar to $align on/off added

git-svn-id: trunk@551 -
florian 20 years ago
parent
commit
08f0419e3e
3 changed files with 82 additions and 42 deletions
  1. 1 0
      .gitattributes
  2. 53 42
      compiler/switches.pas
  3. 28 0
      tests/webtbs/tw3064.pp

+ 1 - 0
.gitattributes

@@ -5925,6 +5925,7 @@ tests/webtbs/tw3041.pp svneol=native#text/plain
 tests/webtbs/tw3045.pp svneol=native#text/plain
 tests/webtbs/tw3045.pp svneol=native#text/plain
 tests/webtbs/tw3048.pp svneol=native#text/plain
 tests/webtbs/tw3048.pp svneol=native#text/plain
 tests/webtbs/tw3063.pp svneol=native#text/plain
 tests/webtbs/tw3063.pp svneol=native#text/plain
+tests/webtbs/tw3064.pp svneol=native#text/plain
 tests/webtbs/tw3073.pp svneol=native#text/plain
 tests/webtbs/tw3073.pp svneol=native#text/plain
 tests/webtbs/tw3082.pp svneol=native#text/plain
 tests/webtbs/tw3082.pp svneol=native#text/plain
 tests/webtbs/tw3083.pp svneol=native#text/plain
 tests/webtbs/tw3083.pp svneol=native#text/plain

+ 53 - 42
compiler/switches.pas

@@ -39,7 +39,7 @@ uses
 ****************************************************************************}
 ****************************************************************************}
 
 
 type
 type
-  TSwitchType=(ignoredsw,localsw,modulesw,globalsw,illegalsw,unsupportedsw);
+  TSwitchType=(ignoredsw,localsw,modulesw,globalsw,illegalsw,unsupportedsw,alignsw);
   SwitchRec=record
   SwitchRec=record
     typesw : TSwitchType;
     typesw : TSwitchType;
     setsw  : byte;
     setsw  : byte;
@@ -48,7 +48,7 @@ type
 
 
 const
 const
   turboSwitchTable: SwitchRecTable =(
   turboSwitchTable: SwitchRecTable =(
-   {A} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
+   {A} (typesw:alignsw; setsw:ord(cs_localnone)),
    {B} (typesw:localsw; setsw:ord(cs_full_boolean_eval)),
    {B} (typesw:localsw; setsw:ord(cs_full_boolean_eval)),
    {C} (typesw:localsw; setsw:ord(cs_do_assertion)),
    {C} (typesw:localsw; setsw:ord(cs_do_assertion)),
    {D} (typesw:modulesw; setsw:ord(cs_debuginfo)),
    {D} (typesw:modulesw; setsw:ord(cs_debuginfo)),
@@ -146,46 +146,57 @@ begin
    with switchTablePtr^[switch] do
    with switchTablePtr^[switch] do
    begin
    begin
      case typesw of
      case typesw of
-     ignoredsw : Message1(scan_n_ignored_switch,'$'+switch);
-     illegalsw : Message1(scan_w_illegal_switch,'$'+switch);
- unsupportedsw : Message1(scan_w_unsupported_switch,'$'+switch);
-       localsw : begin
-                   if not localswitcheschanged then
-                     nextaktlocalswitches:=aktlocalswitches;
-                   if state='+' then
-                    include(nextaktlocalswitches,tlocalswitch(setsw))
-                   else
-                    exclude(nextaktlocalswitches,tlocalswitch(setsw));
-                   localswitcheschanged:=true;
-                 end;
-      modulesw : begin
-                   if current_module.in_global then
-                    begin
-                      if state='+' then
-                        include(aktmoduleswitches,tmoduleswitch(setsw))
-                      else
-                        begin
-                          { Turning off debuginfo when lineinfo is requested
-                            is not possible }
-                          if not((cs_gdb_lineinfo in aktglobalswitches) and
-                                 (tmoduleswitch(setsw)=cs_debuginfo)) then
-                            exclude(aktmoduleswitches,tmoduleswitch(setsw));
-                        end;
-                    end
-                   else
-                    Message(scan_w_switch_is_global);
-                 end;
-      globalsw : begin
-                   if current_module.in_global and (current_module=main_module) then
-                    begin
-                      if state='+' then
-                       include(aktglobalswitches,tglobalswitch(setsw))
-                      else
-                       exclude(aktglobalswitches,tglobalswitch(setsw));
-                    end
-                   else
-                    Message(scan_w_switch_is_global);
-                 end;
+       alignsw:
+         if state='+' then
+           aktpackrecords:=4
+         else
+           aktpackrecords:=1;
+       ignoredsw :
+         Message1(scan_n_ignored_switch,'$'+switch);
+       illegalsw :
+         Message1(scan_w_illegal_switch,'$'+switch);
+       unsupportedsw :
+         Message1(scan_w_unsupported_switch,'$'+switch);
+       localsw :
+         begin
+           if not localswitcheschanged then
+             nextaktlocalswitches:=aktlocalswitches;
+           if state='+' then
+            include(nextaktlocalswitches,tlocalswitch(setsw))
+           else
+            exclude(nextaktlocalswitches,tlocalswitch(setsw));
+           localswitcheschanged:=true;
+         end;
+       modulesw :
+         begin
+           if current_module.in_global then
+            begin
+              if state='+' then
+                include(aktmoduleswitches,tmoduleswitch(setsw))
+              else
+                begin
+                  { Turning off debuginfo when lineinfo is requested
+                    is not possible }
+                  if not((cs_gdb_lineinfo in aktglobalswitches) and
+                         (tmoduleswitch(setsw)=cs_debuginfo)) then
+                    exclude(aktmoduleswitches,tmoduleswitch(setsw));
+                end;
+            end
+           else
+            Message(scan_w_switch_is_global);
+         end;
+       globalsw :
+         begin
+           if current_module.in_global and (current_module=main_module) then
+            begin
+              if state='+' then
+               include(aktglobalswitches,tglobalswitch(setsw))
+              else
+               exclude(aktglobalswitches,tglobalswitch(setsw));
+            end
+           else
+            Message(scan_w_switch_is_global);
+         end;
       end;
       end;
    end;
    end;
 end;
 end;

+ 28 - 0
tests/webtbs/tw3064.pp

@@ -0,0 +1,28 @@
+type
+  r1 = packed record
+    b : byte;
+    l : longint;
+  end;
+  
+  r2 = record
+    b : byte;
+    l : longint;
+  end;
+  
+ {$a-}
+  r3 = record
+    b : byte;
+    l : longint;
+  end;
+  
+ {$a+}
+  r4 = record
+    b : byte;
+    l : longint;
+  end;
+  
+begin
+  if (sizeof(r1)<>sizeof(r3)) or (sizeof(r2)<>sizeof(r4)) then
+    halt(1);
+  writeln('ok');       
+end.