* support for constant char/bool/enum indices in typed constant

index expressions (mantis )
  * prevent all indirect structure indexing instead of only
    ansi/wide/unicodestrings

git-svn-id: trunk@40010 -
This commit is contained in:
Jonas Maebe 2018-10-21 18:48:41 +00:00
parent 2c7c0d1144
commit 2a3eeab96d
3 changed files with 30 additions and 3 deletions

1
.gitattributes vendored
View File

@ -16392,6 +16392,7 @@ tests/webtbs/tw33898.pp -text svneol=native#text/pascal
tests/webtbs/tw3402.pp svneol=native#text/plain
tests/webtbs/tw34021.pp -text svneol=native#text/pascal
tests/webtbs/tw34037.pp svneol=native#text/pascal
tests/webtbs/tw34055.pp svneol=native#text/plain
tests/webtbs/tw3411.pp svneol=native#text/plain
tests/webtbs/tw34124.pp svneol=native#text/pascal
tests/webtbs/tw3418.pp svneol=native#text/plain

View File

@ -916,9 +916,11 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
case hp.nodetype of
vecn :
begin
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
if (is_constintnode(tvecnode(hp).right) or
is_constenumnode(tvecnode(hp).right) or
is_constcharnode(tvecnode(hp).right) or
is_constboolnode(tvecnode(hp).right)) and
not is_implicit_array_pointer(tvecnode(hp).left.resultdef) then
ftcb.queue_vecn(tvecnode(hp).left.resultdef,get_ordinal_value(tvecnode(hp).right))
else
Message(parser_e_illegal_expression);

24
tests/webtbs/tw34055.pp Normal file
View File

@ -0,0 +1,24 @@
{$mode objfpc}
type
TDOS_FIELDNAMES = (
Dos_Signature, // ord = 0
Dos_OffsetToNewExecutable // ord = 1
);
const
DosFieldLabelsB : array[TDOS_FIELDNAMES]
of pwidechar =
(
'DOS signature',
'offset to new executable'
);
d : ppwidechar = @DosFieldLabelsB[Dos_OffsetToNewExecutable];
begin
if d<>@DosFieldLabelsB[Dos_OffsetToNewExecutable] then
halt(1);
end.