* ensure that only the newest message state is applied

This commit is contained in:
Sven/Sarah Barth 2024-12-31 17:18:07 +01:00
parent 1388e2af5b
commit 5ec9386d27
3 changed files with 40 additions and 8 deletions

View File

@ -3755,6 +3755,8 @@ type
specialtoken : tspecialgenerictoken;
i : byte;
pmsg,prevmsg : pmessagestaterecord;
msgset : thashset;
msgfound : boolean;
begin
if not assigned(replaytokenbuf) then
internalerror(200511177);
@ -3863,20 +3865,33 @@ type
begin
{ free pending messages }
FreeLocalVerbosity(pendingstate.nextmessagerecord);
{ the message settings are stored from newest to oldest
change for the whole stack, so we only want to apply
the newest changes for each message type }
mesgnb:=tokenreadsizeint;
msgset:=thashset.create(min(mesgnb,10),false,false);
prevmsg:=nil;
pmsg:=nil;
for i:=1 to mesgnb do
begin
new(pmsg);
if not assigned(pmsg) then
new(pmsg);
pmsg^.value:=tokenreadlongint;
pmsg^.state:=tmsgstate(tokenreadlongint);
pmsg^.next:=nil;
msgfound:=false;
if assigned(msgset.findoradd(@pmsg^.value,sizeof(pmsg^.value),msgfound)) and msgfound then
continue;
if i=1 then
pendingstate.nextmessagerecord:=pmsg
else
prevmsg^.next:=pmsg;
pmsg^.value:=tokenreadlongint;
pmsg^.state:=tmsgstate(tokenreadlongint);
pmsg^.next:=nil;
prevmsg:=pmsg;
pmsg:=nil;
end;
if assigned(pmsg) then
dispose(pmsg);
msgset.free;
end;
ST_LINE:
begin

View File

@ -50,7 +50,7 @@ uses
{ override optimizer switches }
llvminfo,
{$endif llvm}
globals,verbose,comphook,dirparse,
globals,verbose,comphook,dirparse,cclasses,
fmodule;
{****************************************************************************
@ -384,6 +384,8 @@ procedure flushpendingswitchesstate;
var
tmpproccal: tproccalloption;
fstate, pstate : pmessagestaterecord;
msgset : thashset;
msgfound : boolean;
begin
{ process pending localswitches (range checking, etc) }
if psf_local_switches_changed in pendingstate.flags then
@ -423,12 +425,17 @@ procedure flushpendingswitchesstate;
setverbosity(pendingstate.nextverbositystr);
pendingstate.nextverbositystr:='';
end;
msgset:=thashset.create(10,false,false);
fstate:=pendingstate.nextmessagerecord;
pstate:=pendingstate.nextmessagerecord;
while assigned(pstate) do
begin
pendingstate.nextmessagerecord:=pstate^.next;
SetMessageVerbosity(pstate^.value,pstate^.state);
{ the message records are ordered newest to oldest, so only apply the newest change }
msgfound:=false;
if not assigned(msgset.findoradd(@pstate^.value,sizeof(pstate^.value),msgfound)) or
not msgfound then
SetMessageVerbosity(pstate^.value,pstate^.state);
if not assigned(pstate^.next) then
begin
pstate^.next:=current_settings.pmessage;
@ -439,6 +446,7 @@ procedure flushpendingswitchesstate;
pstate:=pstate^.next;
pendingstate.nextmessagerecord:=nil;
end;
msgset.free;
{ process pending calling convention changes (calling x) }
if pendingstate.nextcallingstr<>'' then
begin

View File

@ -114,7 +114,7 @@ interface
implementation
uses
comphook,fmodule,constexp,globals,cfileutl,switches;
comphook,fmodule,constexp,globals,cfileutl,switches,cclasses;
{****************************************************************************
Extra Handlers for default compiler
@ -173,13 +173,22 @@ implementation
end;
procedure RestoreLocalVerbosity(pstate : pmessagestaterecord);
var
msgset : thashset;
msgfound : boolean;
begin
msg^.ResetStates;
msgset:=thashset.create(10,false,false);
while assigned(pstate) do
begin
SetMessageVerbosity(pstate^.value,pstate^.state);
msgfound:=false;
{ only apply the newest message state }
if not assigned(msgset.findoradd(@pstate^.value,sizeof(pstate^.value),msgfound)) or
not msgfound then
SetMessageVerbosity(pstate^.value,pstate^.state);
pstate:=pstate^.next;
end;
msgset.free;
end;
procedure FreeLocalVerbosity(var fstate : pmessagestaterecord);