* (re)store alignment when doing a $push/$pop

git-svn-id: trunk@38020 -
This commit is contained in:
florian 2018-01-22 21:06:07 +00:00
parent 1c149202d8
commit f61b074912
5 changed files with 62 additions and 4 deletions

1
.gitattributes vendored
View File

@ -11955,6 +11955,7 @@ tests/test/cg/tldparam.pp svneol=native#text/plain
tests/test/cg/tloadvmt.pp svneol=native#text/plain
tests/test/cg/tlohi.pp svneol=native#text/plain
tests/test/cg/tlohi2.pp svneol=native#text/pascal
tests/test/cg/tm128.pp svneol=native#text/pascal
tests/test/cg/tmanypar.pp svneol=native#text/plain
tests/test/cg/tmoddiv.pp svneol=native#text/plain
tests/test/cg/tmoddiv1.pp svneol=native#text/plain

View File

@ -220,6 +220,8 @@ interface
nextverbosityfullswitch: longint;
nextcallingstr : shortstring;
nextmessagerecord : pmessagestaterecord;
nextalignment : talignmentinfo;
alignmentchanged,
verbosityfullswitched,
localswitcheschanged : boolean;
end;

View File

@ -26,7 +26,8 @@ unit scandir;
interface
uses
globtype;
globtype,
systems;
const
switchesstatestackmax = 20;
@ -36,6 +37,7 @@ unit scandir;
localsw: tlocalswitches;
verbosity: longint;
pmessage : pmessagestaterecord;
alignment : talignmentinfo;
end;
type
@ -52,7 +54,7 @@ unit scandir;
uses
SysUtils,
cutils,cfileutl,
globals,systems,widestr,cpuinfo,
globals,widestr,cpuinfo,
verbose,comphook,ppu,
scanner,switches,
fmodule,
@ -1172,6 +1174,7 @@ unit scandir;
Dec(switchesstatestackpos);
recordpendinglocalfullswitch(switchesstatestack[switchesstatestackpos].localsw);
recordpendingverbosityfullswitch(switchesstatestack[switchesstatestackpos].verbosity);
recordpendingalignmentfullswitch(switchesstatestack[switchesstatestackpos].alignment);
pendingstate.nextmessagerecord:=switchesstatestack[switchesstatestackpos].pmessage;
{ Reset verbosity and forget previous pmeesage }
RestoreLocalVerbosity(nil);
@ -1209,6 +1212,7 @@ unit scandir;
switchesstatestack[switchesstatestackpos].localsw:= current_settings.localswitches;
switchesstatestack[switchesstatestackpos].pmessage:= current_settings.pmessage;
switchesstatestack[switchesstatestackpos].verbosity:=status.verbosity;
switchesstatestack[switchesstatestackpos].alignment:=current_settings.alignment;
Inc(switchesstatestackpos);
end;

View File

@ -26,7 +26,7 @@ unit switches;
interface
uses
globtype;
systems,globtype;
procedure HandleSwitch(switch,state:char);
function CheckSwitch(switch,state:char):boolean;
@ -37,11 +37,12 @@ procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
procedure recordpendinglocalfullswitch(const switches: tlocalswitches);
procedure recordpendingverbosityfullswitch(verbosity: longint);
procedure recordpendingcallingswitch(const str: shortstring);
procedure recordpendingalignmentfullswitch(const alignment : talignmentinfo);
procedure flushpendingswitchesstate;
implementation
uses
systems,cpuinfo,
cpuinfo,
{$ifdef llvm}
{ override optimizer switches }
llvminfo,
@ -294,6 +295,7 @@ procedure recordpendingverbosityswitch(sw: char; state: char);
pendingstate.nextverbositystr:=pendingstate.nextverbositystr+sw+state;
end;
procedure recordpendingmessagestate(msg: longint; state: tmsgstate);
var
pstate : pmessagestaterecord;
@ -305,6 +307,7 @@ procedure recordpendingmessagestate(msg: longint; state: tmsgstate);
pendingstate.nextmessagerecord:=pstate;
end;
procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
begin
if not pendingstate.localswitcheschanged then
@ -324,6 +327,13 @@ procedure recordpendinglocalswitch(sw: tlocalswitch; state: char);
end;
procedure recordpendingalignmentfullswitch(const alignment : talignmentinfo);
begin
pendingstate.nextalignment:=alignment;
pendingstate.alignmentchanged:=true;
end;
procedure recordpendinglocalfullswitch(const switches: tlocalswitches);
begin
pendingstate.nextlocalswitches:=switches;
@ -361,6 +371,12 @@ procedure flushpendingswitchesstate;
status.verbosity:=pendingstate.nextverbosityfullswitch;
pendingstate.verbosityfullswitched:=false;
end;
if pendingstate.alignmentchanged then
begin
current_settings.alignment:=pendingstate.nextalignment;
pendingstate.alignmentchanged:=false;
end;
{ process pending verbosity changes (warnings on, etc) }
if pendingstate.nextverbositystr<>'' then
begin
setverbosity(pendingstate.nextverbositystr);

35
tests/test/cg/tm128.pp Normal file
View File

@ -0,0 +1,35 @@
{$ASSERTIONS ON}
{$packrecords c}
{$push}
{$codealign recordmin=16}
type
tm128 = record
case byte of
1 : (m128_f32 : array[0..3] of single;)
end;
{$pop}
type
tm128_unaligned = record
case byte of
1 : (m128_f32 : array[0..3] of single;)
end;
var
tr1 : record
b : byte;
m128 : tm128;
end;
tr1_unaligned : record
b : byte;
m128_unaligned : tm128_unaligned;
end;
d : double;
begin
assert((sizeof(tm128))=16);
assert((ptruint(@tr1.m128) mod 16)=0);
assert((ptruint(@tr1_unaligned.m128_unaligned)-ptruint(@tr1_unaligned.b))=4);
end.