* 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:
Jonas Maebe 2010-05-04 10:39:01 +00:00
parent e388ac9770
commit 3f280c34cb
3 changed files with 19 additions and 8 deletions

1
.gitattributes vendored
View File

@ -10353,6 +10353,7 @@ tests/webtbs/tw16326.pp svneol=native#text/plain
tests/webtbs/tw16328.pp svneol=native#text/plain
tests/webtbs/tw1634.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/tw1677.pp svneol=native#text/plain
tests/webtbs/tw1681.pp svneol=native#text/plain

View File

@ -1017,19 +1017,15 @@ implementation
else if (right.location.loc = LOC_JUMP) then
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: }
if cs_check_range in current_settings.localswitches then
begin
if left.resultdef.typ=arraydef then
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
else if (left.resultdef.typ=stringdef) then
begin

14
tests/webtbs/tw16377.pp Normal file
View 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.