mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-11 20:29:14 +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/tb0271.pp svneol=native#text/pascal
|
||||
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/ub0115.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);
|
||||
if pd.is_generic or pd.is_specialization then
|
||||
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
|
||||
// testing and/or RTL patching.
|
||||
@ -1555,10 +1555,6 @@ implementation
|
||||
include(pd.procoptions,po_variadic);
|
||||
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; }
|
||||
if not(check_proc_directive(false)) then
|
||||
begin
|
||||
|
@ -42,6 +42,8 @@ interface
|
||||
|
||||
{ reads a string, file type or a type identifier }
|
||||
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 }
|
||||
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;
|
||||
|
||||
|
||||
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);
|
||||
|
||||
function IsAnonOrLocal: Boolean;
|
||||
@ -1587,7 +1597,7 @@ implementation
|
||||
if is_func then
|
||||
begin
|
||||
consume(_COLON);
|
||||
single_type(pd.returndef,[stoAllowSpecialization]);
|
||||
pd.returndef:=result_type([stoAllowSpecialization]);
|
||||
end;
|
||||
if try_to_consume(_OF) then
|
||||
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