mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 11:38:19 +02:00
* revert check for boolean type when handling LOC_FLAG in tcgassignmentnode.pass_generate_code. This makes pas boolean the default,
resolves #40908
This commit is contained in:
parent
400094921c
commit
9d7ea2c069
@ -1143,7 +1143,33 @@ implementation
|
||||
{$ifdef cpuflags}
|
||||
LOC_FLAGS :
|
||||
begin
|
||||
if is_pasbool(left.resultdef) then
|
||||
{ check for cbool here as booleans converted to other types shall be handled as pas booleans,
|
||||
see also tests/webtbs/tw40908.pp }
|
||||
if is_cbool(left.resultdef) then
|
||||
begin
|
||||
{$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
|
||||
if left.location.size in [OS_S64,OS_64] then
|
||||
begin
|
||||
r64.reglo:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||
r64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||
cg.g_flags2reg(current_asmdata.CurrAsmList,OS_32,right.location.resflags,r64.reglo);
|
||||
cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,r64.reghi);
|
||||
cg64.a_op64_reg_reg(current_asmdata.CurrAsmList,OP_NEG,OS_S64,
|
||||
r64,r64);
|
||||
cg64.a_load64_reg_loc(current_asmdata.CurrAsmList,r64,left.location);
|
||||
end
|
||||
else
|
||||
{$endif not cpu64bitalu and not cpuhighleveltarget}
|
||||
begin
|
||||
r:=cg.getintregister(current_asmdata.CurrAsmList,left.location.size);
|
||||
cg.g_flags2reg(current_asmdata.CurrAsmList,left.location.size,right.location.resflags,r);
|
||||
cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,left.location.size,r,r);
|
||||
hlcg.a_load_reg_loc(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,r,left.location);
|
||||
end
|
||||
end
|
||||
else
|
||||
begin
|
||||
case left.location.loc of
|
||||
LOC_REGISTER,LOC_CREGISTER:
|
||||
@ -1189,30 +1215,6 @@ implementation
|
||||
else
|
||||
internalerror(200203273);
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
|
||||
if left.location.size in [OS_S64,OS_64] then
|
||||
begin
|
||||
r64.reglo:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||
r64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
|
||||
cg.g_flags2reg(current_asmdata.CurrAsmList,OS_32,right.location.resflags,r64.reglo);
|
||||
cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,r64.reghi);
|
||||
cg64.a_op64_reg_reg(current_asmdata.CurrAsmList,OP_NEG,OS_S64,
|
||||
r64,r64);
|
||||
cg64.a_load64_reg_loc(current_asmdata.CurrAsmList,r64,left.location);
|
||||
end
|
||||
else
|
||||
{$endif not cpu64bitalu and not cpuhighleveltarget}
|
||||
begin
|
||||
r:=cg.getintregister(current_asmdata.CurrAsmList,left.location.size);
|
||||
cg.g_flags2reg(current_asmdata.CurrAsmList,left.location.size,right.location.resflags,r);
|
||||
cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
|
||||
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,left.location.size,r,r);
|
||||
hlcg.a_load_reg_loc(current_asmdata.CurrAsmList,left.resultdef,left.resultdef,r,left.location);
|
||||
end
|
||||
end;
|
||||
end;
|
||||
{$endif cpuflags}
|
||||
|
11
tests/webtbs/tw40908.pp
Normal file
11
tests/webtbs/tw40908.pp
Normal file
@ -0,0 +1,11 @@
|
||||
{$minenumsize 1}
|
||||
type
|
||||
MyEnum = (a, b, c);
|
||||
var
|
||||
e: MyEnum;
|
||||
begin
|
||||
e := MyEnum(random(0) = 0);
|
||||
if ord(e)<>1 then
|
||||
halt(1);
|
||||
writeln('sizeof(e) = ', sizeof(e), ', ord(e) = ', ord(e));
|
||||
end.
|
Loading…
Reference in New Issue
Block a user