From 01b5e2b6f6036bf4ac4ec2c80af9828e03fb8bd9 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Wed, 29 Aug 2012 16:09:13 +0000 Subject: [PATCH] * 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 - --- compiler/pdecl.pas | 8 +++++--- compiler/pdecsub.pas | 8 +------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/pdecl.pas b/compiler/pdecl.pas index 8eee372a30..a767771f07 100644 --- a/compiler/pdecl.pas +++ b/compiler/pdecl.pas @@ -35,7 +35,7 @@ interface { pass_1 } 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 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 hp : tconstsym; p : tnode; @@ -92,6 +92,7 @@ implementation internalerror(9584582); hp:=nil; p:=comp_expr(true,false); + nodetype:=p.nodetype; storetokenpos:=current_tokenpos; current_tokenpos:=filepos; case p.nodetype of @@ -194,6 +195,7 @@ implementation dummysymoptions : tsymoptions; deprecatedmsg : pshortstring; storetokenpos,filepos : tfileposinfo; + nodetype : tnodetype; old_block_type : tblock_type; skipequal : boolean; tclist : tasmlist; @@ -210,7 +212,7 @@ implementation _EQ: begin consume(_EQ); - sym:=readconstant(orgname,filepos); + sym:=readconstant(orgname,filepos,nodetype); { Support hint directives } dummysymoptions:=[]; deprecatedmsg:=nil; diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index ada51f3cb6..c080a2b25b 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -256,7 +256,7 @@ implementation bt:=block_type; block_type:=bt_const; { prefix 'def' to the parameter name } - defaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo); + defaultvalue:=ReadConstant('$def'+vs.name,vs.fileinfo,nodetype); block_type:=bt; if assigned(defaultvalue) then begin @@ -264,12 +264,6 @@ implementation pd.parast.insert(defaultvalue); { check whether the default value is of the correct 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 MessagePos2(defaultvalue.fileinfo,type_e_incompatible_types,FullTypeName(defaultvalue.constdef,hdef),FullTypeName(hdef,defaultvalue.constdef)); end;