+ accept system.string, resolves #10489

git-svn-id: trunk@9727 -
This commit is contained in:
florian 2008-01-12 22:25:33 +00:00
parent be2119b489
commit 2d91fef4f1
5 changed files with 56 additions and 12 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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

20
tests/webtbs/tw10489.pp Normal file
View File

@ -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.