Revert r31262. Not doing type checking on generics leads to strange warnings (e.g. because variables are not considered as written). I better deal with the compile time errors one at a time than the warnings.

The added test shows such a bogus warning (sadly the test suite can handle the occurence or absense of certain messages yet :/ )

git-svn-id: trunk@33324 -
This commit is contained in:
svenbarth 2016-03-24 20:58:04 +00:00
parent 56ae2d34b2
commit 35f8d5427f
4 changed files with 80 additions and 49 deletions

1
.gitattributes vendored
View File

@ -10874,6 +10874,7 @@ tests/tbs/tb0613.pp svneol=native#text/pascal
tests/tbs/tb0614.pp svneol=native#text/pascal tests/tbs/tb0614.pp svneol=native#text/pascal
tests/tbs/tb0615.pp svneol=native#text/pascal tests/tbs/tb0615.pp svneol=native#text/pascal
tests/tbs/tb0616.pp svneol=native#text/pascal tests/tbs/tb0616.pp svneol=native#text/pascal
tests/tbs/tb0617.pp svneol=native#text/pascal
tests/tbs/tb205.pp svneol=native#text/plain tests/tbs/tb205.pp svneol=native#text/plain
tests/tbs/tb610.pp svneol=native#text/pascal tests/tbs/tb610.pp svneol=native#text/pascal
tests/tbs/tb613.pp svneol=native#text/plain tests/tbs/tb613.pp svneol=native#text/plain

View File

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

View File

@ -1869,8 +1869,6 @@ implementation
entrypos:=code.fileinfo; entrypos:=code.fileinfo;
{ Finish type checking pass } { 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); do_typecheckpass(code);
if assigned(procdef.parentfpinitblock) then if assigned(procdef.parentfpinitblock) then

37
tests/tbs/tb0617.pp Normal file
View File

@ -0,0 +1,37 @@
{ %NORUN }
program tb0617;
{$mode objfpc}
type
generic TGenericStructList<T> = class
public
function Remove(const Item: T): Integer;
procedure Delete(Index: Integer);
function IndexOf(const Item: T): Integer;
end;
function TGenericStructList.Remove(const Item: T): Integer;
begin
Result := IndexOf(Item);
{ for some reason, FPC 3.1.1 makes here incorrect warning:
castlegenericlists.pas(254,13) Warning: Function result variable does not seem to be initialized }
if Result >= 0 then
Delete(Result);
end;
function TGenericStructList.IndexOf(const Item: T): Integer;
begin
Result := 0;
end;
procedure TGenericStructList.Delete(Index: Integer);
begin
end;
begin
end.