summaryrefslogtreecommitdiff
path: root/compiler/ngtcon.pas
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-02-01 17:09:00 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2015-02-01 17:09:00 +0000
commitfdaa23986fdc657e3d621684f581124269c83fa0 (patch)
tree19b4f892fe2c4a9dff2a599f0417250beff2f6cb /compiler/ngtcon.pas
parentb01093cf2e9f2a9053ed772d000106a5e5306741 (diff)
downloadfpc-fdaa23986fdc657e3d621684f581124269c83fa0.tar.gz
* read array initializations in generic subroutines without fixed limits, resolves #25602
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@29598 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/ngtcon.pas')
-rw-r--r--compiler/ngtcon.pas43
1 files changed, 31 insertions, 12 deletions
diff --git a/compiler/ngtcon.pas b/compiler/ngtcon.pas
index 71a5b0d184..eb3cf8a46e 100644
--- a/compiler/ngtcon.pas
+++ b/compiler/ngtcon.pas
@@ -1109,21 +1109,40 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
begin
oldoffset:=curoffset;
curoffset:=0;
- for i:=def.lowrange to def.highrange-1 do
+ { in case of a generic subroutine, it might be we cannot
+ determine the size yet }
+ if assigned(current_procinfo) and (df_generic in current_procinfo.procdef.defoptions) then
begin
- read_typed_const_data(def.elementdef);
- Inc(curoffset,def.elementdef.size);
- if token=_RKLAMMER then
+ while true do
begin
- Message1(parser_e_more_array_elements_expected,tostr(def.highrange-i));
- consume(_RKLAMMER);
- exit;
- end
- else
- consume(_COMMA);
+ read_typed_const_data(def.elementdef);
+ if token=_RKLAMMER then
+ begin
+ consume(_RKLAMMER);
+ break;
+ end
+ else
+ consume(_COMMA);
+ end;
+ end
+ else
+ begin
+ for i:=def.lowrange to def.highrange-1 do
+ begin
+ read_typed_const_data(def.elementdef);
+ Inc(curoffset,def.elementdef.size);
+ if token=_RKLAMMER then
+ begin
+ Message1(parser_e_more_array_elements_expected,tostr(def.highrange-i));
+ consume(_RKLAMMER);
+ exit;
+ end
+ else
+ consume(_COMMA);
+ end;
+ read_typed_const_data(def.elementdef);
+ consume(_RKLAMMER);
end;
- read_typed_const_data(def.elementdef);
- consume(_RKLAMMER);
curoffset:=oldoffset;
end
{ if array of char then we allow also a string }