* check function/procedure type when adding a proc definition

git-svn-id: trunk@546 -
This commit is contained in:
peter 2005-06-30 14:56:05 +00:00
parent 3e97ec6295
commit c1b2e1aac5
10 changed files with 55 additions and 30 deletions

1
.gitattributes vendored
View File

@ -4423,6 +4423,7 @@ tests/tbf/tb0174a.pp svneol=native#text/plain
tests/tbf/tb0174b.pp svneol=native#text/plain tests/tbf/tb0174b.pp svneol=native#text/plain
tests/tbf/tb0174c.pp svneol=native#text/plain tests/tbf/tb0174c.pp svneol=native#text/plain
tests/tbf/tb0174d.pp svneol=native#text/plain tests/tbf/tb0174d.pp svneol=native#text/plain
tests/tbf/tb0175.pp svneol=native#text/plain
tests/tbf/ub0115.pp svneol=native#text/plain tests/tbf/ub0115.pp svneol=native#text/plain
tests/tbf/ub0149.pp svneol=native#text/plain tests/tbf/ub0149.pp svneol=native#text/plain
tests/tbf/ub0158a.pp svneol=native#text/plain tests/tbf/ub0158a.pp svneol=native#text/plain

View File

@ -1414,7 +1414,7 @@ unit cgcpu;
make_global : boolean; make_global : boolean;
href : treference; href : treference;
begin begin
if procdef.proctypeoption<>potype_none then if not(procdef.proctypeoption in [potype_function,potype_procedure]) then
Internalerror(200006137); Internalerror(200006137);
if not assigned(procdef._class) or if not assigned(procdef._class) or
(procdef.procoptions*[po_classmethod, po_staticmethod, (procdef.procoptions*[po_classmethod, po_staticmethod,

View File

@ -529,7 +529,7 @@ unit cgcpu;
make_global : boolean; make_global : boolean;
href : treference; href : treference;
begin begin
if procdef.proctypeoption<>potype_none then if not(procdef.proctypeoption in [potype_function,potype_procedure]) then
Internalerror(200006137); Internalerror(200006137);
if not assigned(procdef._class) or if not assigned(procdef._class) or
(procdef.procoptions*[po_classmethod, po_staticmethod, (procdef.procoptions*[po_classmethod, po_staticmethod,

View File

@ -878,7 +878,7 @@ implementation
_FUNCTION : _FUNCTION :
begin begin
consume(_FUNCTION); consume(_FUNCTION);
if parse_proc_head(aclass,potype_none,pd) then if parse_proc_head(aclass,potype_function,pd) then
begin begin
{ pd=nil when it is a interface mapping } { pd=nil when it is a interface mapping }
if assigned(pd) then if assigned(pd) then
@ -917,7 +917,7 @@ implementation
_PROCEDURE : _PROCEDURE :
begin begin
consume(_PROCEDURE); consume(_PROCEDURE);
if parse_proc_head(aclass,potype_none,pd) then if parse_proc_head(aclass,potype_procedure,pd) then
begin begin
{ pd=nil when it is a interface mapping } { pd=nil when it is a interface mapping }
if assigned(pd) then if assigned(pd) then

View File

@ -2034,7 +2034,7 @@ const
var var
make_global : boolean; make_global : boolean;
begin begin
if procdef.proctypeoption<>potype_none then if not(procdef.proctypeoption in [potype_function,potype_procedure]) then
Internalerror(200006137); Internalerror(200006137);
if not assigned(procdef._class) or if not assigned(procdef._class) or
(procdef.procoptions*[po_classmethod, po_staticmethod, (procdef.procoptions*[po_classmethod, po_staticmethod,

View File

@ -1263,7 +1263,7 @@ implementation
make_global : boolean; make_global : boolean;
href : treference; href : treference;
begin begin
if procdef.proctypeoption<>potype_none then if not(procdef.proctypeoption in [potype_function,potype_procedure]) then
Internalerror(200006137); Internalerror(200006137);
if not assigned(procdef._class) or if not assigned(procdef._class) or
(procdef.procoptions*[po_classmethod, po_staticmethod, (procdef.procoptions*[po_classmethod, po_staticmethod,

View File

@ -219,7 +219,9 @@ type
potype_unitfinalize, { unit finalization } potype_unitfinalize, { unit finalization }
potype_constructor, { Procedure is a constructor } potype_constructor, { Procedure is a constructor }
potype_destructor, { Procedure is a destructor } potype_destructor, { Procedure is a destructor }
potype_operator { Procedure defines an operator } potype_operator, { Procedure defines an operator }
potype_procedure,
potype_function
); );
tproctypeoptions=set of tproctypeoption; tproctypeoptions=set of tproctypeoption;

View File

@ -807,7 +807,9 @@ type
potype_unitfinalize, { unit finalization } potype_unitfinalize, { unit finalization }
potype_constructor, { Procedure is a constructor } potype_constructor, { Procedure is a constructor }
potype_destructor, { Procedure is a destructor } potype_destructor, { Procedure is a destructor }
potype_operator { Procedure defines an operator } potype_operator, { Procedure defines an operator }
potype_procedure,
potype_function
); );
tproctypeoptions=set of tproctypeoption; tproctypeoptions=set of tproctypeoption;
tprocoption=(po_none, tprocoption=(po_none,
@ -877,14 +879,16 @@ const
'SoftFloat', 'SoftFloat',
'MWPascal' 'MWPascal'
); );
proctypeopts=6; proctypeopts=8;
proctypeopt : array[1..proctypeopts] of tproctypeopt=( proctypeopt : array[1..proctypeopts] of tproctypeopt=(
(mask:potype_proginit; str:'ProgInit'), (mask:potype_proginit; str:'ProgInit'),
(mask:potype_unitinit; str:'UnitInit'), (mask:potype_unitinit; str:'UnitInit'),
(mask:potype_unitfinalize;str:'UnitFinalize'), (mask:potype_unitfinalize;str:'UnitFinalize'),
(mask:potype_constructor; str:'Constructor'), (mask:potype_constructor; str:'Constructor'),
(mask:potype_destructor; str:'Destructor'), (mask:potype_destructor; str:'Destructor'),
(mask:potype_operator; str:'Operator') (mask:potype_operator; str:'Operator'),
(mask:potype_function; str:'Function'),
(mask:potype_procedure; str:'Procedure')
); );
procopts=26; procopts=26;
procopt : array[1..procopts] of tprocopt=( procopt : array[1..procopts] of tprocopt=(
@ -925,8 +929,6 @@ begin
readtype; readtype;
writeln(space,' Fpu used : ',ppufile.getbyte); writeln(space,' Fpu used : ',ppufile.getbyte);
proctypeoption:=tproctypeoption(ppufile.getbyte); proctypeoption:=tproctypeoption(ppufile.getbyte);
if proctypeoption<>potype_none then
begin
write(space,' TypeOption : '); write(space,' TypeOption : ');
first:=true; first:=true;
for i:=1 to proctypeopts do for i:=1 to proctypeopts do
@ -939,7 +941,6 @@ begin
write(proctypeopt[i].str); write(proctypeopt[i].str);
end; end;
writeln; writeln;
end;
proccalloption:=tproccalloption(ppufile.getbyte); proccalloption:=tproccalloption(ppufile.getbyte);
writeln(space,' CallOption : ',proccalloptionStr[proccalloption]); writeln(space,' CallOption : ',proccalloptionStr[proccalloption]);
ppufile.getsmallset(procoptions); ppufile.getsmallset(procoptions);

View File

@ -90,7 +90,7 @@ unit cgcpu;
make_global : boolean; make_global : boolean;
href : treference; href : treference;
begin begin
if procdef.proctypeoption<>potype_none then if not(procdef.proctypeoption in [potype_function,potype_procedure]) then
Internalerror(200006137); Internalerror(200006137);
if not assigned(procdef._class) or if not assigned(procdef._class) or
(procdef.procoptions*[po_classmethod, po_staticmethod, (procdef.procoptions*[po_classmethod, po_staticmethod,

21
tests/tbf/tb0175.pp Executable file
View File

@ -0,0 +1,21 @@
{$ifdef fpc}
{$Mode Delphi}
{$endif}
unit tb0175;
interface
function getvar: string;
implementation
var
myvar : string;
procedure getvar;
begin
result := myvar;
end;
end.