* give an error when trying to get the address of an element of a dynamic

string in a typed constant, like Delphi (instead of generating a bogus
    address)

git-svn-id: trunk@33958 -
This commit is contained in:
Jonas Maebe 2016-06-12 09:20:57 +00:00
parent 8bc39ba7a3
commit b8ed0fac5d
5 changed files with 33 additions and 1 deletions

3
.gitattributes vendored
View File

@ -10343,6 +10343,9 @@ tests/tbf/tb0248.pp svneol=native#text/pascal
tests/tbf/tb0249.pp svneol=native#text/pascal
tests/tbf/tb0250.pp svneol=native#text/pascal
tests/tbf/tb0251.pp svneol=native#text/pascal
tests/tbf/tb0252a.pp svneol=native#text/plain
tests/tbf/tb0252b.pp svneol=native#text/plain
tests/tbf/tb0252c.pp svneol=native#text/plain
tests/tbf/ub0115.pp svneol=native#text/plain
tests/tbf/ub0149.pp svneol=native#text/plain
tests/tbf/ub0158a.pp svneol=native#text/plain

View File

@ -919,7 +919,9 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
case hp.nodetype of
vecn :
begin
if is_constintnode(tvecnode(hp).right) then
if is_constintnode(tvecnode(hp).right) and
not is_ansistring(tvecnode(hp).left.resultdef) and
not is_wide_or_unicode_string(tvecnode(hp).left.resultdef) then
ftcb.queue_vecn(tvecnode(hp).left.resultdef,get_ordinal_value(tvecnode(hp).right))
else
Message(parser_e_illegal_expression);

9
tests/tbf/tb0252a.pp Normal file
View File

@ -0,0 +1,9 @@
{ %FAIL }
const
s : ansistring = 'test';
pc : pchar = @s[1];
begin
end.

9
tests/tbf/tb0252b.pp Normal file
View File

@ -0,0 +1,9 @@
{ %FAIL }
const
w : widestring = 'abcdef';
pw : pwidechar = @w[3];
begin
end.

9
tests/tbf/tb0252c.pp Normal file
View File

@ -0,0 +1,9 @@
{ %FAIL }
const
u : unicodestring = '123456879';
pu : punicodechar = @u[4];
begin
end.