mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 10:49:09 +02:00
* use the parsed node type for checking the validity of default parameter
values instead of a default based on the resulting constsym (more robust) git-svn-id: trunk@22267 -
This commit is contained in:
parent
ad054831bb
commit
01b5e2b6f6
@ -35,7 +35,7 @@ interface
|
|||||||
{ pass_1 }
|
{ pass_1 }
|
||||||
node;
|
node;
|
||||||
|
|
||||||
function readconstant(const orgname:string;const filepos:tfileposinfo):tconstsym;
|
function readconstant(const orgname:string;const filepos:tfileposinfo; out nodetype: tnodetype):tconstsym;
|
||||||
|
|
||||||
procedure const_dec;
|
procedure const_dec;
|
||||||
procedure consts_dec(in_structure, allow_typed_const: boolean);
|
procedure consts_dec(in_structure, allow_typed_const: boolean);
|
||||||
@ -76,7 +76,7 @@ implementation
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
function readconstant(const orgname:string;const filepos:tfileposinfo):tconstsym;
|
function readconstant(const orgname:string;const filepos:tfileposinfo; out nodetype: tnodetype):tconstsym;
|
||||||
var
|
var
|
||||||
hp : tconstsym;
|
hp : tconstsym;
|
||||||
p : tnode;
|
p : tnode;
|
||||||
@ -92,6 +92,7 @@ implementation
|
|||||||
internalerror(9584582);
|
internalerror(9584582);
|
||||||
hp:=nil;
|
hp:=nil;
|
||||||
p:=comp_expr(true,false);
|
p:=comp_expr(true,false);
|
||||||
|
nodetype:=p.nodetype;
|
||||||
storetokenpos:=current_tokenpos;
|
storetokenpos:=current_tokenpos;
|
||||||
current_tokenpos:=filepos;
|
current_tokenpos:=filepos;
|
||||||
case p.nodetype of
|
case p.nodetype of
|
||||||
@ -194,6 +195,7 @@ implementation
|
|||||||
dummysymoptions : tsymoptions;
|
dummysymoptions : tsymoptions;
|
||||||
deprecatedmsg : pshortstring;
|
deprecatedmsg : pshortstring;
|
||||||
storetokenpos,filepos : tfileposinfo;
|
storetokenpos,filepos : tfileposinfo;
|
||||||
|
nodetype : tnodetype;
|
||||||
old_block_type : tblock_type;
|
old_block_type : tblock_type;
|
||||||
skipequal : boolean;
|
skipequal : boolean;
|
||||||
tclist : tasmlist;
|
tclist : tasmlist;
|
||||||
@ -210,7 +212,7 @@ implementation
|
|||||||
_EQ:
|
_EQ:
|
||||||
begin
|
begin
|
||||||
consume(_EQ);
|
consume(_EQ);
|
||||||
sym:=readconstant(orgname,filepos);
|
sym:=readconstant(orgname,filepos,nodetype);
|
||||||
{ Support hint directives }
|
{ Support hint directives }
|
||||||
dummysymoptions:=[];
|
dummysymoptions:=[];
|
||||||
deprecatedmsg:=nil;
|
deprecatedmsg:=nil;
|
||||||
|
@ -256,7 +256,7 @@ implementation
|
|||||||
bt:=block_type;
|
bt:=block_type;
|
||||||
block_type:=bt_const;
|
block_type:=bt_const;
|
||||||
{ prefix 'def' to the parameter name }
|
{ prefix 'def' to the parameter name }
|
||||||
defaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo);
|
defaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo,nodetype);
|
||||||
block_type:=bt;
|
block_type:=bt;
|
||||||
if assigned(defaultvalue) then
|
if assigned(defaultvalue) then
|
||||||
begin
|
begin
|
||||||
@ -264,12 +264,6 @@ implementation
|
|||||||
pd.parast.insert(defaultvalue);
|
pd.parast.insert(defaultvalue);
|
||||||
{ check whether the default value is of the correct
|
{ check whether the default value is of the correct
|
||||||
type }
|
type }
|
||||||
if defaultvalue.consttyp in [conststring,constwstring] then
|
|
||||||
nodetype:=stringconstn
|
|
||||||
else if defaultvalue.consttyp=constnil then
|
|
||||||
nodetype:=niln
|
|
||||||
else
|
|
||||||
nodetype:=nothingn;
|
|
||||||
if compare_defs_ext(defaultvalue.constdef,hdef,nodetype,doconv,convpd,[])<=te_convert_operator then
|
if compare_defs_ext(defaultvalue.constdef,hdef,nodetype,doconv,convpd,[])<=te_convert_operator then
|
||||||
MessagePos2(defaultvalue.fileinfo,type_e_incompatible_types,FullTypeName(defaultvalue.constdef,hdef),FullTypeName(hdef,defaultvalue.constdef));
|
MessagePos2(defaultvalue.fileinfo,type_e_incompatible_types,FullTypeName(defaultvalue.constdef,hdef),FullTypeName(hdef,defaultvalue.constdef));
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user