mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-25 15:09:56 +02:00
* apply slightly adjusted patch by Blaise.ru which moves parsing of result types to a separate functions thus ensuring that File types can't be used for procedure variables (just like they already couldn't be used as a result type for normal functions)
+ added test git-svn-id: trunk@47810 -
This commit is contained in:
parent
a1b252538f
commit
2a897f5b6b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -12735,6 +12735,7 @@ tests/tbf/tb0269.pp svneol=native#text/pascal
|
|||||||
tests/tbf/tb0270.pp svneol=native#text/pascal
|
tests/tbf/tb0270.pp svneol=native#text/pascal
|
||||||
tests/tbf/tb0271.pp svneol=native#text/pascal
|
tests/tbf/tb0271.pp svneol=native#text/pascal
|
||||||
tests/tbf/tb0272.pp svneol=native#text/plain
|
tests/tbf/tb0272.pp svneol=native#text/plain
|
||||||
|
tests/tbf/tb0273.pp svneol=native#text/pascal
|
||||||
tests/tbf/tb0588.pp svneol=native#text/pascal
|
tests/tbf/tb0588.pp svneol=native#text/pascal
|
||||||
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
|
||||||
|
@ -1344,7 +1344,7 @@ implementation
|
|||||||
parse_generic:=(df_generic in pd.defoptions);
|
parse_generic:=(df_generic in pd.defoptions);
|
||||||
if pd.is_generic or pd.is_specialization then
|
if pd.is_generic or pd.is_specialization then
|
||||||
symtablestack.push(pd.parast);
|
symtablestack.push(pd.parast);
|
||||||
single_type(pd.returndef,[stoAllowSpecialization]);
|
pd.returndef:=result_type([stoAllowSpecialization]);
|
||||||
|
|
||||||
// Issue #24863, enabled only for the main progra commented out for now because it breaks building of RTL and needs extensive
|
// Issue #24863, enabled only for the main progra commented out for now because it breaks building of RTL and needs extensive
|
||||||
// testing and/or RTL patching.
|
// testing and/or RTL patching.
|
||||||
@ -1555,10 +1555,6 @@ implementation
|
|||||||
include(pd.procoptions,po_variadic);
|
include(pd.procoptions,po_variadic);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ file types can't be function results }
|
|
||||||
if assigned(pd) and
|
|
||||||
(pd.returndef.typ=filedef) then
|
|
||||||
message(parser_e_illegal_function_result);
|
|
||||||
{ support procedure proc stdcall export; }
|
{ support procedure proc stdcall export; }
|
||||||
if not(check_proc_directive(false)) then
|
if not(check_proc_directive(false)) then
|
||||||
begin
|
begin
|
||||||
|
@ -42,6 +42,8 @@ interface
|
|||||||
|
|
||||||
{ reads a string, file type or a type identifier }
|
{ reads a string, file type or a type identifier }
|
||||||
procedure single_type(out def:tdef;options:TSingleTypeOptions);
|
procedure single_type(out def:tdef;options:TSingleTypeOptions);
|
||||||
|
{ ... but rejects types that cannot be returned from functions }
|
||||||
|
function result_type(options:TSingleTypeOptions):tdef;
|
||||||
|
|
||||||
{ reads any type declaration, where the resulting type will get name as type identifier }
|
{ reads any type declaration, where the resulting type will get name as type identifier }
|
||||||
procedure read_named_type(var def:tdef;const newsym:tsym;genericdef:tstoreddef;genericlist:tfphashobjectlist;parseprocvardir:boolean;var hadtypetoken:boolean);
|
procedure read_named_type(var def:tdef;const newsym:tsym;genericdef:tstoreddef;genericlist:tfphashobjectlist;parseprocvardir:boolean;var hadtypetoken:boolean);
|
||||||
@ -645,6 +647,14 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function result_type(options:TSingleTypeOptions):tdef;
|
||||||
|
begin
|
||||||
|
single_type(result,options);
|
||||||
|
{ file types cannot be function results }
|
||||||
|
if result.typ=filedef then
|
||||||
|
message(parser_e_illegal_function_result);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure parse_record_members(recsym:tsym);
|
procedure parse_record_members(recsym:tsym);
|
||||||
|
|
||||||
function IsAnonOrLocal: Boolean;
|
function IsAnonOrLocal: Boolean;
|
||||||
@ -1587,7 +1597,7 @@ implementation
|
|||||||
if is_func then
|
if is_func then
|
||||||
begin
|
begin
|
||||||
consume(_COLON);
|
consume(_COLON);
|
||||||
single_type(pd.returndef,[stoAllowSpecialization]);
|
pd.returndef:=result_type([stoAllowSpecialization]);
|
||||||
end;
|
end;
|
||||||
if try_to_consume(_OF) then
|
if try_to_consume(_OF) then
|
||||||
begin
|
begin
|
||||||
|
8
tests/tbf/tb0273.pp
Normal file
8
tests/tbf/tb0273.pp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{ %FAIL }
|
||||||
|
|
||||||
|
// EXPECTED: 'Error: Illegal function result type'
|
||||||
|
// ACTUAL: gets compiled
|
||||||
|
type M = function : file;
|
||||||
|
|
||||||
|
begin
|
||||||
|
end.
|
Loading…
Reference in New Issue
Block a user