mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-29 21:51:37 +01:00
* check function/procedure type when adding a proc definition
git-svn-id: trunk@546 -
This commit is contained in:
parent
3e97ec6295
commit
c1b2e1aac5
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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,21 +929,18 @@ 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
|
write(space,' TypeOption : ');
|
||||||
begin
|
first:=true;
|
||||||
write(space,' TypeOption : ');
|
for i:=1 to proctypeopts do
|
||||||
first:=true;
|
if (proctypeopt[i].mask=proctypeoption) then
|
||||||
for i:=1 to proctypeopts do
|
begin
|
||||||
if (proctypeopt[i].mask=proctypeoption) then
|
if first then
|
||||||
begin
|
first:=false
|
||||||
if first then
|
else
|
||||||
first:=false
|
write(', ');
|
||||||
else
|
write(proctypeopt[i].str);
|
||||||
write(', ');
|
end;
|
||||||
write(proctypeopt[i].str);
|
writeln;
|
||||||
end;
|
|
||||||
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);
|
||||||
|
|||||||
@ -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
21
tests/tbf/tb0175.pp
Executable 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.
|
||||||
Loading…
Reference in New Issue
Block a user