* convert array indices always to s32int, because that is the index type used

by java arrays (otherwise we may get unwanted sign extensions after
    performing e.g. an s16bit operation, see the test)

git-svn-id: trunk@26472 -
This commit is contained in:
Jonas Maebe 2014-01-15 20:36:52 +00:00
parent 67413a2823
commit a5653916e0
3 changed files with 14 additions and 0 deletions

View File

@ -427,6 +427,14 @@ implementation
object instances (since that's what they are in Java) } object instances (since that's what they are in Java) }
right.resultdef:=s32inttype; right.resultdef:=s32inttype;
right.location.size:=OS_S32; right.location.size:=OS_S32;
end
else if (right.location.loc<>LOC_CONSTANT) and
((right.resultdef.typ<>orddef) or
(torddef(right.resultdef).ordtype<>s32bit)) then
begin
{ Java array indices are always 32 bit signed integers }
hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,s32inttype,true);
right.resultdef:=s32inttype;
end; end;
{ adjust index if necessary } { adjust index if necessary }

View File

@ -280,3 +280,7 @@ ppcjvm -O2 -g -B -CTinitlocals tinitvar
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%
javaa -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. org.freepascal.test.tinitvar.tinitvar javaa -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. org.freepascal.test.tinitvar.tinitvar
if %errorlevel% neq 0 exit /b %errorlevel% if %errorlevel% neq 0 exit /b %errorlevel%
ppcjvm -O2 -g -B -CTinitlocals tsmallintarr
if %errorlevel% neq 0 exit /b %errorlevel%
javaa -Dfile.encoding=UTF-8 -cp ..\..\..\rtl\units\jvm-java;. tsmallintarr
if %errorlevel% neq 0 exit /b %errorlevel%

View File

@ -156,3 +156,5 @@ javac -encoding utf-8 -cp ../../../rtl/units/$RTLDIR:. tjavalowercaseproc.java
java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tjavalowercaseproc java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tjavalowercaseproc
$PPC -O2 -g -B -Sa -CTinitlocals tinitvar $PPC -O2 -g -B -Sa -CTinitlocals tinitvar
java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. org.freepascal.test.tinitvar.tinitvar java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. org.freepascal.test.tinitvar.tinitvar
$PPC -O2 -g -B -Sa tsmallintarr
java -Dfile.encoding=UTF-8 -cp ../../../rtl/units/$RTLDIR:. tsmallintarr