* do not call typecheckpass unncessarily in generic definitions, it might cause only errors, resolves #28058

git-svn-id: trunk@31262 -
This commit is contained in:
florian 2015-08-02 20:29:30 +00:00
parent f1decfb6b6
commit 9a55e8fa3c
4 changed files with 70 additions and 41 deletions

1
.gitattributes vendored
View File

@ -14661,6 +14661,7 @@ tests/webtbs/tw27998.pp svneol=native#text/plain
tests/webtbs/tw27998a.pp svneol=native#text/plain
tests/webtbs/tw28007.pp svneol=native#text/pascal
tests/webtbs/tw2803.pp svneol=native#text/plain
tests/webtbs/tw28058.pp svneol=native#text/pascal
tests/webtbs/tw2806.pp svneol=native#text/plain
tests/webtbs/tw2807.pp svneol=native#text/plain
tests/webtbs/tw28089.pp svneol=native#text/plain

View File

@ -1284,6 +1284,9 @@ implementation
if p.nodetype in [vecn,derefn,typeconvn,subscriptn,loadn] then
maybe_call_procvar(p,false);
{ additional checks make no sense in a generic definition }
if not(df_generic in current_procinfo.procdef.defoptions) then
begin
{ blockn support because a read/write is changed into a blocknode
with a separate statement for each read/write operation (JM)
the same is true for val() if the third parameter is not 32 bit
@ -1327,10 +1330,13 @@ implementation
) then
Message(parser_e_illegal_expression);
end;
end;
code:=p;
end;
end;
if assigned(code) then
if assigned(code) and
{ type checking makes no sense in a generic definition }
not(df_generic in current_procinfo.procdef.defoptions) then
begin
typecheckpass(code);
code.fileinfo:=filepos;

View File

@ -1855,6 +1855,8 @@ implementation
entrypos:=code.fileinfo;
{ Finish type checking pass }
{ type checking makes no sense in a generic definition }
if not(df_generic in current_procinfo.procdef.defoptions) then
do_typecheckpass(code);
if assigned(procdef.parentfpinitblock) then

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

@ -0,0 +1,20 @@
{$mode objfpc}
program Project1;
type
generic TFoo<T> = class
const
Size = SizeOf(T);
public
function X: Integer;
end;
{ TFoo }
function TFoo.X: Integer;
begin
//Result := 100 div SizeOf(T);
Result := 100 div Size;
end;
begin
end.