mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 13:29:14 +02:00
* correctly handle LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF in second_int_to_bool, resolves issue #28007
git-svn-id: trunk@30765 -
This commit is contained in:
parent
8ee9550d22
commit
b222d0b663
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -14417,6 +14417,7 @@ tests/webtbs/tw2788.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw27880.pp svneol=native#text/plain
|
tests/webtbs/tw27880.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2789.pp svneol=native#text/plain
|
tests/webtbs/tw2789.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2794.pp svneol=native#text/plain
|
tests/webtbs/tw2794.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw28007.pp svneol=native#text/pascal
|
||||||
tests/webtbs/tw2803.pp svneol=native#text/plain
|
tests/webtbs/tw2803.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2806.pp svneol=native#text/plain
|
tests/webtbs/tw2806.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw2807.pp svneol=native#text/plain
|
tests/webtbs/tw2807.pp svneol=native#text/plain
|
||||||
|
@ -163,6 +163,10 @@ implementation
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
|
LOC_SUBSETREG,
|
||||||
|
LOC_CSUBSETREG,
|
||||||
|
LOC_SUBSETREF,
|
||||||
|
LOC_CSUBSETREF,
|
||||||
LOC_CREFERENCE,
|
LOC_CREFERENCE,
|
||||||
LOC_REFERENCE,
|
LOC_REFERENCE,
|
||||||
LOC_REGISTER,
|
LOC_REGISTER,
|
||||||
|
@ -314,6 +314,10 @@ implementation
|
|||||||
|
|
||||||
{ Load left node into flag F_NE/F_E }
|
{ Load left node into flag F_NE/F_E }
|
||||||
resflags:=F_NE;
|
resflags:=F_NE;
|
||||||
|
|
||||||
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
LOC_CREFERENCE,
|
LOC_CREFERENCE,
|
||||||
LOC_REFERENCE :
|
LOC_REFERENCE :
|
||||||
|
@ -199,6 +199,10 @@ implementation
|
|||||||
|
|
||||||
newsize:=def_cgsize(resultdef);
|
newsize:=def_cgsize(resultdef);
|
||||||
opsize := def_cgsize(left.resultdef);
|
opsize := def_cgsize(left.resultdef);
|
||||||
|
|
||||||
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
LOC_CREFERENCE,LOC_REFERENCE :
|
LOC_CREFERENCE,LOC_REFERENCE :
|
||||||
begin
|
begin
|
||||||
|
@ -207,26 +207,30 @@ begin
|
|||||||
if codegenerror then
|
if codegenerror then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
{ Explicit typecasts from any ordinal type to a boolean type }
|
{ Explicit typecasts from any ordinal type to a boolean type }
|
||||||
{ must not change the ordinal value }
|
{ must not change the ordinal value }
|
||||||
if (nf_explicit in flags) and
|
if (nf_explicit in flags) and
|
||||||
not(left.location.loc in [LOC_FLAGS,LOC_JUMP]) then
|
not(left.location.loc in [LOC_FLAGS,LOC_JUMP]) then
|
||||||
begin
|
begin
|
||||||
location_copy(location,left.location);
|
location_copy(location,left.location);
|
||||||
newsize:=def_cgsize(resultdef);
|
newsize:=def_cgsize(resultdef);
|
||||||
{ change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
|
{ change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
|
||||||
if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
|
if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
|
||||||
((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
|
((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
|
||||||
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
|
||||||
else
|
else
|
||||||
location.size:=newsize;
|
location.size:=newsize;
|
||||||
current_procinfo.CurrTrueLabel:=oldTrueLabel;
|
current_procinfo.CurrTrueLabel:=oldTrueLabel;
|
||||||
current_procinfo.CurrFalseLabel:=oldFalseLabel;
|
current_procinfo.CurrFalseLabel:=oldFalseLabel;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
location_reset(location, LOC_REGISTER, def_cgsize(resultdef));
|
location_reset(location, LOC_REGISTER, def_cgsize(resultdef));
|
||||||
opsize := def_cgsize(left.resultdef);
|
opsize := def_cgsize(left.resultdef);
|
||||||
|
|
||||||
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
LOC_CREFERENCE, LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER:
|
LOC_CREFERENCE, LOC_REFERENCE, LOC_REGISTER, LOC_CREGISTER:
|
||||||
begin
|
begin
|
||||||
|
@ -110,6 +110,10 @@ implementation
|
|||||||
if (opsize in [OS_64,OS_S64]) then
|
if (opsize in [OS_64,OS_S64]) then
|
||||||
opsize:=OS_32;
|
opsize:=OS_32;
|
||||||
{$endif not cpu64bitalu}
|
{$endif not cpu64bitalu}
|
||||||
|
|
||||||
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER :
|
LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER :
|
||||||
begin
|
begin
|
||||||
|
@ -264,6 +264,10 @@ implementation
|
|||||||
|
|
||||||
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
||||||
opsize:=def_cgsize(left.resultdef);
|
opsize:=def_cgsize(left.resultdef);
|
||||||
|
|
||||||
|
if (left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
|
||||||
|
|
||||||
case left.location.loc of
|
case left.location.loc of
|
||||||
LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
|
LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
|
||||||
begin
|
begin
|
||||||
|
29
tests/webtbs/tw28007.pp
Normal file
29
tests/webtbs/tw28007.pp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
program error_record;
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
TPackedBool = bitpacked record
|
||||||
|
b0: Boolean;
|
||||||
|
b1: Boolean;
|
||||||
|
b2: Boolean;
|
||||||
|
b3: Boolean;
|
||||||
|
b4: Boolean;
|
||||||
|
b5: Boolean;
|
||||||
|
b6: Boolean;
|
||||||
|
b7: Boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
B: ByteBool;
|
||||||
|
PackedBool: TPackedBool;
|
||||||
|
|
||||||
|
begin
|
||||||
|
(*
|
||||||
|
- OK on x86, x86_64 compiler
|
||||||
|
- ERROR on cross arm compiler
|
||||||
|
- OK on cross arm compiler if we do typecast:
|
||||||
|
B := ByteBool(PackedBool.b0);
|
||||||
|
*)
|
||||||
|
|
||||||
|
B := PackedBool.b0;
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user