From 80fef1e8adc1b8610b2b9590f89a8eb836b5939d Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 22 Dec 2005 12:21:06 +0000 Subject: [PATCH] * fix parsing of typecasts in type declarations git-svn-id: trunk@2026 - --- compiler/globtype.pas | 2 +- compiler/pexpr.pas | 4 ++-- compiler/ptype.pas | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index a8817ecca4..c0d6664465 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -177,7 +177,7 @@ than 255 characters. That's why using Ansi Strings} { currently parsed block type } tblock_type = (bt_none, - bt_general,bt_type,bt_const,bt_except,bt_body + bt_general,bt_type,bt_const,bt_except,bt_body,bt_specialize ); { Temp types } diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 5f82a29916..41544ec7d3 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1312,7 +1312,7 @@ implementation if (htype.def=cvarianttype.def) and not(cs_compilesystem in aktmoduleswitches) then current_module.flags:=current_module.flags or uf_uses_variants; - if (block_type<>bt_type) and + if (block_type<>bt_specialize) and try_to_consume(_LKLAMMER) then begin p1:=comp_expr(true); @@ -1392,7 +1392,7 @@ implementation { For a type block we simply return only the type. For all other blocks we return a loadvmt node } - if (block_type<>bt_type) then + if not(block_type in [bt_type,bt_specialize]) then p1:=cloadvmtaddrnode.create(p1); end; end diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 4fc47ace73..751d506d3c 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -359,7 +359,9 @@ implementation pt1,pt2 : tnode; lv,hv : TConstExprInt; ispecialization : boolean; + old_block_type : tblock_type; begin + old_block_type:=block_type; { use of current parsed object: - classes can be used also in classes - objects can be parameters } @@ -376,12 +378,13 @@ implementation exit; end; { Generate a specialization? } - ispecialization:=try_to_consume(_SPECIALIZE); + if try_to_consume(_SPECIALIZE) then + block_type:=bt_specialize; { we can't accept a equal in type } pt1:=comp_expr(not(ignore_equal)); - if (token=_POINTPOINT) then + if (block_type<>bt_specialize) and + try_to_consume(_POINTPOINT) then begin - consume(_POINTPOINT); { get high value of range } pt2:=comp_expr(not(ignore_equal)); { make both the same type or give an error. This is not @@ -427,7 +430,7 @@ implementation { a simple type renaming or generic specialization } if (pt1.nodetype=typen) then begin - if ispecialization then + if (block_type=bt_specialize) then generate_specialization(pt1,name); tt:=ttypenode(pt1).resulttype; end @@ -435,6 +438,7 @@ implementation Message(sym_e_error_in_type_def); end; pt1.free; + block_type:=old_block_type; end; procedure array_dec;