* give a proper error when a rangen appears in a vecn that's not an

array parameter (mantis )

git-svn-id: trunk@14368 -
This commit is contained in:
Jonas Maebe 2009-12-08 18:47:24 +00:00
parent b9b95a8f73
commit b521f80b13
3 changed files with 26 additions and 1 deletions

1
.gitattributes vendored
View File

@ -9493,6 +9493,7 @@ tests/webtbf/tw14849.pp svneol=native#text/plain
tests/webtbf/tw14929a.pp svneol=native#text/plain
tests/webtbf/tw14929b.pp svneol=native#text/plain
tests/webtbf/tw14946.pp svneol=native#text/plain
tests/webtbf/tw15287.pp svneol=native#text/plain
tests/webtbf/tw15288.pp svneol=native#text/plain
tests/webtbf/tw1599.pp svneol=native#text/plain
tests/webtbf/tw1599b.pp svneol=native#text/plain

View File

@ -893,7 +893,12 @@ implementation
else if is_widestring(left.resultdef) and (tf_winlikewidestring in target_info.flags) then
exclude(flags,nf_callunique);
if (not is_packed_array(left.resultdef)) or
{ a range node as array index can only appear in function calls, and
those convert the range node into something else in
tcallnode.gen_high_tree }
if (right.nodetype=rangen) then
CGMessagePos(right.fileinfo,parser_e_illegal_expression)
else if (not is_packed_array(left.resultdef)) or
((tarraydef(left.resultdef).elepackedbitsize mod 8) = 0) then
if left.expectloc=LOC_CREFERENCE then
expectloc:=LOC_CREFERENCE

19
tests/webtbf/tw15287.pp Normal file
View File

@ -0,0 +1,19 @@
{ %fail }
program arrayrangeoperator;
{$mode objfpc}{$H+}
uses
Classes, SysUtils;
type
TArrayOfInteger = array of integer;
var
a, b: TArrayOfInteger;
begin
SetLength(a,10);
b:=a[2..4];
end.