From 2d91fef4f1bb656e4aeb2082cc94d48c39aa387e Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 12 Jan 2008 22:25:33 +0000 Subject: [PATCH] + accept system.string, resolves #10489 git-svn-id: trunk@9727 - --- .gitattributes | 1 + compiler/pbase.pas | 37 +++++++++++++++++++++++++++++-------- compiler/pexpr.pas | 5 +++-- compiler/ptype.pas | 5 +++-- tests/webtbs/tw10489.pp | 20 ++++++++++++++++++++ 5 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 tests/webtbs/tw10489.pp diff --git a/.gitattributes b/.gitattributes index fd855845f5..625019152a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7966,6 +7966,7 @@ tests/webtbs/tw10425.pp svneol=native#text/plain tests/webtbs/tw1044.pp svneol=native#text/plain tests/webtbs/tw10454.pp svneol=native#text/plain tests/webtbs/tw1046.pp svneol=native#text/plain +tests/webtbs/tw10489.pp svneol=native#text/plain tests/webtbs/tw1050.pp svneol=native#text/plain tests/webtbs/tw10540.pp svneol=native#text/plain tests/webtbs/tw1061.pp svneol=native#text/plain diff --git a/compiler/pbase.pas b/compiler/pbase.pas index 9c1fcaf6b8..d5522afc0f 100644 --- a/compiler/pbase.pas +++ b/compiler/pbase.pas @@ -88,7 +88,7 @@ interface function consume_sym(var srsym:tsym;var srsymtable:TSymtable):boolean; function consume_sym_orgid(var srsym:tsym;var srsymtable:TSymtable;var s : string):boolean; - function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable):boolean; + function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean; function try_consume_hintdirective(var symopt:tsymoptions):boolean; @@ -100,7 +100,7 @@ interface implementation uses - globals,htypechk,scanner,systems,verbose; + globals,htypechk,scanner,systems,verbose,fmodule; {**************************************************************************** Token Parsing @@ -177,6 +177,8 @@ implementation must be changed as well (FK) } function consume_sym(var srsym:tsym;var srsymtable:TSymtable):boolean; + var + t : ttoken; begin { first check for identifier } if token<>_ID then @@ -189,7 +191,7 @@ implementation end; searchsym(pattern,srsym,srsymtable); { handle unit specification like System.Writeln } - try_consume_unitsym(srsym,srsymtable); + try_consume_unitsym(srsym,srsymtable,t); { if nothing found give error and return errorsym } if assigned(srsym) then check_hints(srsym,srsym.symoptions) @@ -199,7 +201,7 @@ implementation srsym:=generrorsym; srsymtable:=nil; end; - consume(_ID); + consume(t); result:=assigned(srsym); end; @@ -208,6 +210,8 @@ implementation if required and returns the id with it's original casing } function consume_sym_orgid(var srsym:tsym;var srsymtable:TSymtable;var s : string):boolean; + var + t : ttoken; begin { first check for identifier } if token<>_ID then @@ -220,7 +224,7 @@ implementation end; searchsym(pattern,srsym,srsymtable); { handle unit specification like System.Writeln } - try_consume_unitsym(srsym,srsymtable); + try_consume_unitsym(srsym,srsymtable,t); { if nothing found give error and return errorsym } if assigned(srsym) then check_hints(srsym,srsym.symoptions) @@ -231,13 +235,15 @@ implementation srsymtable:=nil; end; s:=orgpattern; - consume(_ID); + consume(t); result:=assigned(srsym); end; - function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable):boolean; + + function try_consume_unitsym(var srsym:tsym;var srsymtable:TSymtable;var tokentoconsume : ttoken):boolean; begin result:=false; + tokentoconsume:=_ID; if assigned(srsym) and (srsym.typ=unitsym) then begin @@ -249,7 +255,22 @@ implementation begin consume(_ID); consume(_POINT); - searchsym_in_module(tunitsym(srsym).module,pattern,srsym,srsymtable); + case token of + _ID: + searchsym_in_module(tunitsym(srsym).module,pattern,srsym,srsymtable); + _STRING: + begin + { system.string? } + if tmodule(tunitsym(srsym).module).globalsymtable=systemunit then + begin + if cs_ansistrings in current_settings.localswitches then + searchsym_in_module(tunitsym(srsym).module,'ANSISTRING',srsym,srsymtable) + else + searchsym_in_module(tunitsym(srsym).module,'SHORTSTRING',srsym,srsymtable); + tokentoconsume:=_STRING; + end; + end + end; end else begin diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index e47379682f..fc8fe848d4 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1367,6 +1367,7 @@ implementation orgstoredpattern, storedpattern : string; len : longint; + t : ttoken; begin { allow post fix operators } again:=true; @@ -1383,10 +1384,10 @@ implementation searchsym(pattern,srsym,srsymtable); { handle unit specification like System.Writeln } - unit_found:=try_consume_unitsym(srsym,srsymtable); + unit_found:=try_consume_unitsym(srsym,srsymtable,t); storedpattern:=pattern; orgstoredpattern:=orgpattern; - consume(_ID); + consume(t); { named parameter support } found_arg_name:=false; diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 39f9decca3..17b80c6068 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -277,6 +277,7 @@ implementation srsym : tsym; srsymtable : TSymtable; s,sorg : TIDString; + t : ttoken; begin s:=pattern; sorg:=orgpattern; @@ -299,8 +300,8 @@ implementation parameters } searchsym_type(s,srsym,srsymtable); { handle unit specification like System.Writeln } - is_unit_specific:=try_consume_unitsym(srsym,srsymtable); - consume(_ID); + is_unit_specific:=try_consume_unitsym(srsym,srsymtable,t); + consume(t); { Types are first defined with an error def before assigning the real type so check if it's an errordef. if so then give an error. Only check for typesyms in the current symbol diff --git a/tests/webtbs/tw10489.pp b/tests/webtbs/tw10489.pp new file mode 100644 index 0000000000..7ead3f666f --- /dev/null +++ b/tests/webtbs/tw10489.pp @@ -0,0 +1,20 @@ +{$mode objfpc} +program test; + +uses + TypInfo; + +function GetTypeInfo(const i: Integer): PTypeInfo; +begin + case i of + 0: Result := TypeInfo(System.Integer); + 1: Result := TypeInfo(System.Int64); + 2: Result := TypeInfo(System.String); //syntax error + 3: Result := TypeInfo(System.WideString); + else + Result := nil; + end; +end; + +begin +end.