mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-10 09:29:13 +02:00
* don't print range check warnings when evaluating inlined explicit typecasts
git-svn-id: trunk@46904 -
This commit is contained in:
parent
e83d214e98
commit
9f42931eeb
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13350,6 +13350,7 @@ tests/tbs/tb0673.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0674.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0675.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0676.pp svneol=native#text/pascal
|
||||
tests/tbs/tb0676a.pp svneol=native#text/plain
|
||||
tests/tbs/ub0060.pp svneol=native#text/plain
|
||||
tests/tbs/ub0069.pp svneol=native#text/plain
|
||||
tests/tbs/ub0119.pp svneol=native#text/plain
|
||||
|
@ -3175,7 +3175,13 @@ implementation
|
||||
if (target_info.endian = endian_big) and (nf_absolute in flags) then
|
||||
swap_const_value(tordconstnode(left).value,tordconstnode(left).resultdef.size);
|
||||
if not(nf_generic_para in flags) then
|
||||
adaptrange(resultdef,tordconstnode(left).value,([nf_internal,nf_absolute]*flags)<>[],nf_explicit in flags,cs_check_range in localswitches);
|
||||
adaptrange(
|
||||
resultdef,tordconstnode(left).value,
|
||||
{ when evaluating an explicit typecast during inlining, don't warn about
|
||||
lost bits; only warn if someone literally typed e.g. byte($1ff) }
|
||||
(([nf_internal,nf_absolute]*flags)<>[]) or (forinline and (nf_explicit in flags)),
|
||||
nf_explicit in flags,
|
||||
cs_check_range in localswitches);
|
||||
{ swap value back, but according to new type }
|
||||
if (target_info.endian = endian_big) and (nf_absolute in flags) then
|
||||
swap_const_value(tordconstnode(left).value,resultdef.size);
|
||||
|
20
tests/tbs/tb0676a.pp
Normal file
20
tests/tbs/tb0676a.pp
Normal file
@ -0,0 +1,20 @@
|
||||
{ %opt=-vw -Sew }
|
||||
{ %norun }
|
||||
|
||||
{$mode objfpc}
|
||||
|
||||
function SwapEndian(const AValue: Word): Word;inline;
|
||||
begin
|
||||
Result := Word((AValue shr 8) or (AValue shl 8));
|
||||
end;
|
||||
|
||||
const
|
||||
Value = 8008;
|
||||
|
||||
var
|
||||
v: Word;
|
||||
begin
|
||||
writeln(sizeof(Value));
|
||||
Writeln(HexStr(Value, 4));
|
||||
v := swapendian(Value);
|
||||
Writeln(HexStr(v, 4));
|
Loading…
Reference in New Issue
Block a user