mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-30 01:11:27 +01:00
* don't generate range checking code for pointers-indexed-as-arrays when
using non-constant indices (mantis #16377) git-svn-id: trunk@15221 -
This commit is contained in:
parent
e388ac9770
commit
3f280c34cb
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -10353,6 +10353,7 @@ tests/webtbs/tw16326.pp svneol=native#text/plain
|
|||||||
tests/webtbs/tw16328.pp svneol=native#text/plain
|
tests/webtbs/tw16328.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1634.pp svneol=native#text/plain
|
tests/webtbs/tw1634.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw16366.pp svneol=native#text/plain
|
tests/webtbs/tw16366.pp svneol=native#text/plain
|
||||||
|
tests/webtbs/tw16377.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1658.pp svneol=native#text/plain
|
tests/webtbs/tw1658.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1677.pp svneol=native#text/plain
|
tests/webtbs/tw1677.pp svneol=native#text/plain
|
||||||
tests/webtbs/tw1681.pp svneol=native#text/plain
|
tests/webtbs/tw1681.pp svneol=native#text/plain
|
||||||
|
|||||||
@ -1017,19 +1017,15 @@ implementation
|
|||||||
else if (right.location.loc = LOC_JUMP) then
|
else if (right.location.loc = LOC_JUMP) then
|
||||||
internalerror(2006010801);
|
internalerror(2006010801);
|
||||||
|
|
||||||
{ only range check now, we can't range check loc_flags/loc_jump }
|
|
||||||
if cs_check_range in current_settings.localswitches then
|
|
||||||
begin
|
|
||||||
if left.resultdef.typ=arraydef then
|
|
||||||
rangecheck_array;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ produce possible range check code: }
|
{ produce possible range check code: }
|
||||||
if cs_check_range in current_settings.localswitches then
|
if cs_check_range in current_settings.localswitches then
|
||||||
begin
|
begin
|
||||||
if left.resultdef.typ=arraydef then
|
if left.resultdef.typ=arraydef then
|
||||||
begin
|
begin
|
||||||
{ done defore (PM) }
|
{ do not do any range checking when this is an array access to a pointer which has been
|
||||||
|
typecasted from an array }
|
||||||
|
if (not (ado_isconvertedpointer in tarraydef(left.resultdef).arrayoptions)) then
|
||||||
|
rangecheck_array
|
||||||
end
|
end
|
||||||
else if (left.resultdef.typ=stringdef) then
|
else if (left.resultdef.typ=stringdef) then
|
||||||
begin
|
begin
|
||||||
|
|||||||
14
tests/webtbs/tw16377.pp
Normal file
14
tests/webtbs/tw16377.pp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
program project1;
|
||||||
|
const
|
||||||
|
S: string = '123';
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
P: PChar;
|
||||||
|
begin
|
||||||
|
{$RANGECHECKS ON}
|
||||||
|
P := PChar(@S[2]);
|
||||||
|
I := -1;
|
||||||
|
if (P[-1]<>'1') or
|
||||||
|
(P[I]<>'1') then
|
||||||
|
halt(1);
|
||||||
|
end.
|
||||||
Loading…
Reference in New Issue
Block a user