Convert the Boolean parameters accept_equal, typeonly and hadspecialize of comp_expr(), sub_expr() and factor() to a set parameter and adjust all calls.

pexpr.pas:
  + new enum texprflag and corresponding set texprflags
  * comp_expr: replace accept_equal and typeonly with texprflags parameter
  * factor: replace typeonly and hadspecialize with texprflags parameter
  * sub_expr: replace accept_equal and typeonly with texprflags parameter
  * adjust calls to comp_expr(), factor() and sub_expr()
other units:
  * adjust calls to comp_expr(), factor() and sub_expr() 

git-svn-id: trunk@32269 -
This commit is contained in:
svenbarth 2015-11-07 21:45:03 +00:00
parent 4edbd27774
commit 0ff87336aa
11 changed files with 170 additions and 162 deletions

View File

@ -182,7 +182,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
n : tnode; n : tnode;
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
{ for C-style booleans, true=-1 and false=0) } { for C-style booleans, true=-1 and false=0) }
if is_cbool(def) then if is_cbool(def) then
inserttypeconv(n,def); inserttypeconv(n,def);
@ -194,7 +194,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
n : tnode; n : tnode;
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
tc_emit_floatdef(def,n); tc_emit_floatdef(def,n);
n.free; n.free;
end; end;
@ -203,7 +203,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
n : tnode; n : tnode;
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
case n.nodetype of case n.nodetype of
loadvmtaddrn: loadvmtaddrn:
begin begin
@ -222,7 +222,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
p: tnode; p: tnode;
begin begin
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
tc_emit_pointerdef(def,p); tc_emit_pointerdef(def,p);
p.free; p.free;
end; end;
@ -231,7 +231,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
p : tnode; p : tnode;
begin begin
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
tc_emit_setdef(def,p); tc_emit_setdef(def,p);
p.free; p.free;
end; end;
@ -240,7 +240,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
p : tnode; p : tnode;
begin begin
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
tc_emit_enumdef(def,p); tc_emit_enumdef(def,p);
p.free; p.free;
end; end;
@ -249,7 +249,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
var var
n : tnode; n : tnode;
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
tc_emit_stringdef(def,n); tc_emit_stringdef(def,n);
n.free; n.free;
end; end;
@ -1060,7 +1060,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
node: tnode; node: tnode;
begin begin
result:=true; result:=true;
node:=comp_expr(true,false); node:=comp_expr([ef_accept_equal]);
if (node.nodetype <> ordconstn) or if (node.nodetype <> ordconstn) or
(not equal_defs(node.resultdef,def) and (not equal_defs(node.resultdef,def) and
not is_subequal(node.resultdef,def)) then not is_subequal(node.resultdef,def)) then
@ -1199,7 +1199,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
begin begin
ftcb.maybe_begin_aggregate(def); ftcb.maybe_begin_aggregate(def);
char_size:=def.elementdef.size; char_size:=def.elementdef.size;
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
if n.nodetype=stringconstn then if n.nodetype=stringconstn then
begin begin
len:=tstringconstnode(n).len; len:=tstringconstnode(n).len;
@ -1331,7 +1331,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
Message(parser_e_no_procvarobj_const); Message(parser_e_no_procvarobj_const);
{ parse the rest too, so we can continue with error checking } { parse the rest too, so we can continue with error checking }
getprocvardef:=def; getprocvardef:=def;
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
getprocvardef:=nil; getprocvardef:=nil;
if codegenerror then if codegenerror then
begin begin
@ -1445,7 +1445,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
{ GUID } { GUID }
if (def=rec_tguid) and (token=_ID) then if (def=rec_tguid) and (token=_ID) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
if n.nodetype=stringconstn then if n.nodetype=stringconstn then
handle_stringconstn handle_stringconstn
else else
@ -1461,7 +1461,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
end; end;
if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
inserttypeconv(n,cshortstringtype); inserttypeconv(n,cshortstringtype);
if n.nodetype=stringconstn then if n.nodetype=stringconstn then
handle_stringconstn handle_stringconstn
@ -1659,7 +1659,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
{ only allow nil for implicit pointer object types } { only allow nil for implicit pointer object types }
if is_implicit_pointer_object_type(def) then if is_implicit_pointer_object_type(def) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
if n.nodetype<>niln then if n.nodetype<>niln then
begin begin
Message(parser_e_type_const_not_possible); Message(parser_e_type_const_not_possible);
@ -1810,7 +1810,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
{ if array of char then we allow also a string } { if array of char then we allow also a string }
else if is_anychar(def.elementdef) then else if is_anychar(def.elementdef) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
addstatement(statmnt,cassignmentnode.create_internal(basenode,n)); addstatement(statmnt,cassignmentnode.create_internal(basenode,n));
basenode:=nil; basenode:=nil;
end end
@ -1824,7 +1824,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
procedure tnodetreetypedconstbuilder.parse_procvardef(def: tprocvardef); procedure tnodetreetypedconstbuilder.parse_procvardef(def: tprocvardef);
begin begin
addstatement(statmnt,cassignmentnode.create_internal(basenode,comp_expr(true,false))); addstatement(statmnt,cassignmentnode.create_internal(basenode,comp_expr([ef_accept_equal])));
basenode:=nil; basenode:=nil;
end; end;
@ -1853,7 +1853,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
{ GUID } { GUID }
if (def=rec_tguid) and (token=_ID) then if (def=rec_tguid) and (token=_ID) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
if n.nodetype=stringconstn then if n.nodetype=stringconstn then
handle_stringconstn handle_stringconstn
else else
@ -1874,7 +1874,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
end; end;
if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then if (def=rec_tguid) and ((token=_CSTRING) or (token=_CCHAR)) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
inserttypeconv(n,cshortstringtype); inserttypeconv(n,cshortstringtype);
if n.nodetype=stringconstn then if n.nodetype=stringconstn then
handle_stringconstn handle_stringconstn
@ -2020,7 +2020,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
{ only allow nil for implicit pointer object types } { only allow nil for implicit pointer object types }
if is_implicit_pointer_object_type(def) then if is_implicit_pointer_object_type(def) then
begin begin
n:=comp_expr(true,false); n:=comp_expr([ef_accept_equal]);
if n.nodetype<>niln then if n.nodetype<>niln then
begin begin
Message(parser_e_type_const_not_possible); Message(parser_e_type_const_not_possible);

View File

@ -85,7 +85,7 @@ implementation
if orgname='' then if orgname='' then
internalerror(9584582); internalerror(9584582);
hp:=nil; hp:=nil;
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
nodetype:=p.nodetype; nodetype:=p.nodetype;
storetokenpos:=current_tokenpos; storetokenpos:=current_tokenpos;
current_tokenpos:=filepos; current_tokenpos:=filepos;
@ -666,7 +666,7 @@ implementation
{ check if it is an ansistirng(codepage) declaration } { check if it is an ansistirng(codepage) declaration }
if is_ansistring(hdef) and try_to_consume(_LKLAMMER) then if is_ansistring(hdef) and try_to_consume(_LKLAMMER) then
begin begin
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
if not is_constintnode(p) then if not is_constintnode(p) then
begin begin
@ -989,7 +989,7 @@ implementation
_EQ: _EQ:
begin begin
consume(_EQ); consume(_EQ);
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
storetokenpos:=current_tokenpos; storetokenpos:=current_tokenpos;
current_tokenpos:=filepos; current_tokenpos:=filepos;
sym:=nil; sym:=nil;

View File

@ -399,7 +399,7 @@ implementation
p : tnode; p : tnode;
valid : boolean; valid : boolean;
begin begin
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
if p.nodetype=stringconstn then if p.nodetype=stringconstn then
begin begin
stringdispose(current_objectdef.iidstr); stringdispose(current_objectdef.iidstr);

View File

@ -818,7 +818,7 @@ implementation
var var
node : tnode; node : tnode;
begin begin
node:=factor(false,true,true); node:=factor(false,[ef_type_only,ef_had_specialize]);
if node.nodetype=typen then if node.nodetype=typen then
begin begin
sp:=ttypenode(node).typedef.typesym.name; sp:=ttypenode(node).typedef.typesym.name;
@ -1865,7 +1865,7 @@ var pt:Tnode;
begin begin
if pd.typ<>procdef then if pd.typ<>procdef then
internalerror(200604301); internalerror(200604301);
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if is_constintnode(pt) then if is_constintnode(pt) then
if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then
message3(type_e_range_check_error_bounds,tostr(Tordconstnode(pt).value),tostr(low(longint)),tostr(high(longint))) message3(type_e_range_check_error_bounds,tostr(Tordconstnode(pt).value),tostr(low(longint)),tostr(high(longint)))
@ -1950,7 +1950,7 @@ begin
if paracnt<>1 then if paracnt<>1 then
Message(parser_e_ill_msg_param); Message(parser_e_ill_msg_param);
end; end;
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
{ message is 1-character long } { message is 1-character long }
if is_constcharnode(pt) then if is_constcharnode(pt) then
begin begin

View File

@ -181,7 +181,7 @@ implementation
if def.typ=arraydef then if def.typ=arraydef then
begin begin
idx:=0; idx:=0;
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
if (not codegenerror) then if (not codegenerror) then
begin begin
if (p.nodetype=ordconstn) then if (p.nodetype=ordconstn) then
@ -284,7 +284,7 @@ implementation
if try_to_consume(_DISPID) then if try_to_consume(_DISPID) then
begin begin
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if is_constintnode(pt) then if is_constintnode(pt) then
if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then if (Tordconstnode(pt).value<int64(low(longint))) or (Tordconstnode(pt).value>int64(high(longint))) then
message3(type_e_range_check_error_bounds,tostr(Tordconstnode(pt).value),tostr(low(longint)),tostr(high(longint))) message3(type_e_range_check_error_bounds,tostr(Tordconstnode(pt).value),tostr(low(longint)),tostr(high(longint)))
@ -448,7 +448,7 @@ implementation
if (idtoken=_INDEX) then if (idtoken=_INDEX) then
begin begin
consume(_INDEX); consume(_INDEX);
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
{ Only allow enum and integer indexes. Convert all integer { Only allow enum and integer indexes. Convert all integer
values to objpas.integer (s32int on 32- and 64-bit targets, values to objpas.integer (s32int on 32- and 64-bit targets,
s16int on 16- and 8-bit) to be compatible with delphi, s16int on 16- and 8-bit) to be compatible with delphi,
@ -661,14 +661,14 @@ implementation
begin begin
Message(parser_e_property_cant_have_a_default_value); Message(parser_e_property_cant_have_a_default_value);
{ Error recovery } { Error recovery }
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
pt.free; pt.free;
end end
else else
begin begin
{ Get the result of the default, the firstpass is { Get the result of the default, the firstpass is
needed to support values like -1 } needed to support values like -1 }
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if (p.propdef.typ=setdef) and if (p.propdef.typ=setdef) and
(pt.nodetype=arrayconstructorn) then (pt.nodetype=arrayconstructorn) then
begin begin
@ -1773,12 +1773,12 @@ implementation
fillchar(variantdesc^^.branches[high(variantdesc^^.branches)], fillchar(variantdesc^^.branches[high(variantdesc^^.branches)],
sizeof(variantdesc^^.branches[high(variantdesc^^.branches)]),0); sizeof(variantdesc^^.branches[high(variantdesc^^.branches)]),0);
repeat repeat
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if not(pt.nodetype=ordconstn) then if not(pt.nodetype=ordconstn) then
Message(parser_e_illegal_expression); Message(parser_e_illegal_expression);
{ iso pascal does not support ranges in variant record definitions } { iso pascal does not support ranges in variant record definitions }
if not(m_iso in current_settings.modeswitches) and try_to_consume(_POINTPOINT) then if not(m_iso in current_settings.modeswitches) and try_to_consume(_POINTPOINT) then
pt:=crangenode.create(pt,comp_expr(true,false)) pt:=crangenode.create(pt,comp_expr([ef_accept_equal]))
else else
begin begin
with variantdesc^^.branches[high(variantdesc^^.branches)] do with variantdesc^^.branches[high(variantdesc^^.branches)] do

View File

@ -136,7 +136,7 @@ implementation
end; end;
if try_to_consume(_INDEX) then if try_to_consume(_INDEX) then
begin begin
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if pt.nodetype=ordconstn then if pt.nodetype=ordconstn then
if (Tordconstnode(pt).value<int64(low(index))) or if (Tordconstnode(pt).value<int64(low(index))) or
(Tordconstnode(pt).value>int64(high(index))) then (Tordconstnode(pt).value>int64(high(index))) then
@ -160,7 +160,7 @@ implementation
end; end;
if try_to_consume(_NAME) then if try_to_consume(_NAME) then
begin begin
pt:=comp_expr(true,false); pt:=comp_expr([ef_accept_equal]);
if pt.nodetype=stringconstn then if pt.nodetype=stringconstn then
hpname:=strpas(tstringconstnode(pt).value_str) hpname:=strpas(tstringconstnode(pt).value_str)
else if is_constcharnode(pt) then else if is_constcharnode(pt) then

View File

@ -31,14 +31,22 @@ interface
tokens,globtype,globals,constexp, tokens,globtype,globals,constexp,
pgentype; pgentype;
type
texprflag = (
ef_accept_equal,
ef_type_only,
ef_had_specialize
);
texprflags = set of texprflag;
{ reads a whole expression } { reads a whole expression }
function expr(dotypecheck:boolean) : tnode; function expr(dotypecheck:boolean) : tnode;
{ reads an expression without assignements and .. } { reads an expression without assignements and .. }
function comp_expr(accept_equal,typeonly:boolean):tnode; function comp_expr(flags:texprflags):tnode;
{ reads a single factor } { reads a single factor }
function factor(getaddr,typeonly,hadspecialize:boolean) : tnode; function factor(getaddr:boolean;flags:texprflags) : tnode;
procedure string_dec(var def: tdef; allowtypedef: boolean); procedure string_dec(var def: tdef; allowtypedef: boolean);
@ -74,7 +82,7 @@ implementation
pbase,pinline,ptype,pgenutil,procinfo,cpuinfo pbase,pinline,ptype,pgenutil,procinfo,cpuinfo
; ;
function sub_expr(pred_level:Toperator_precedence;accept_equal,typeonly:boolean;factornode:tnode):tnode;forward; function sub_expr(pred_level:Toperator_precedence;flags:texprflags;factornode:tnode):tnode;forward;
const const
{ true, if the inherited call is anonymous } { true, if the inherited call is anonymous }
@ -96,7 +104,7 @@ implementation
if not(allowtypedef) then if not(allowtypedef) then
Message(parser_e_no_local_para_def); Message(parser_e_no_local_para_def);
consume(_LECKKLAMMER); consume(_LECKKLAMMER);
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
if not is_constintnode(p) then if not is_constintnode(p) then
begin begin
Message(parser_e_illegal_expression); Message(parser_e_illegal_expression);
@ -172,12 +180,12 @@ implementation
else else
begin begin
named_args_allowed:=true; named_args_allowed:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
named_args_allowed:=false; named_args_allowed:=false;
if found_arg_name then if found_arg_name then
begin begin
argname:=p1; argname:=p1;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
tcallparanode(p2).parametername:=argname; tcallparanode(p2).parametername:=argname;
end end
@ -188,19 +196,19 @@ implementation
end end
else else
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
end; end;
{ it's for the str(l:5,s); } { it's for the str(l:5,s); }
if __colon and (token=_COLON) then if __colon and (token=_COLON) then
begin begin
consume(_COLON); consume(_COLON);
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
include(tcallparanode(p2).callparaflags,cpf_is_colon_para); include(tcallparanode(p2).callparaflags,cpf_is_colon_para);
if try_to_consume(_COLON) then if try_to_consume(_COLON) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
include(tcallparanode(p2).callparaflags,cpf_is_colon_para); include(tcallparanode(p2).callparaflags,cpf_is_colon_para);
end end
@ -284,7 +292,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=geninlinenode(in_ord_x,false,p1); p1:=geninlinenode(in_ord_x,false,p1);
statement_syssym := p1; statement_syssym := p1;
@ -299,7 +307,7 @@ implementation
begin begin
if not(try_to_consume(_RKLAMMER)) then if not(try_to_consume(_RKLAMMER)) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
if not assigned(current_procinfo) or if not assigned(current_procinfo) or
(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) or (current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) or
@ -397,7 +405,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
if p1.nodetype=typen then if p1.nodetype=typen then
ttypenode(p1).allowed:=true; ttypenode(p1).allowed:=true;
@ -424,7 +432,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
if ((p1.nodetype<>typen) and if ((p1.nodetype<>typen) and
@ -475,7 +483,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
{ When reading a class type it is parsed as loadvmtaddrn, { When reading a class type it is parsed as loadvmtaddrn,
typeinfo only needs the type so we remove the loadvmtaddrn } typeinfo only needs the type so we remove the loadvmtaddrn }
if p1.nodetype=loadvmtaddrn then if p1.nodetype=loadvmtaddrn then
@ -515,7 +523,7 @@ implementation
err:=false; err:=false;
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=ccallparanode.create(p1,nil); p2:=ccallparanode.create(p1,nil);
p2:=geninlinenode(l,false,p2); p2:=geninlinenode(l,false,p2);
consume(_RKLAMMER); consume(_RKLAMMER);
@ -527,7 +535,7 @@ implementation
err:=false; err:=false;
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
{ When reading a class type it is parsed as loadvmtaddrn, { When reading a class type it is parsed as loadvmtaddrn,
typeinfo only needs the type so we remove the loadvmtaddrn } typeinfo only needs the type so we remove the loadvmtaddrn }
if p1.nodetype=loadvmtaddrn then if p1.nodetype=loadvmtaddrn then
@ -584,10 +592,10 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
got_addrn:=true; got_addrn:=true;
p1:=factor(true,false,false); p1:=factor(true,[]);
{ inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp } { inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp }
if token<>_RKLAMMER then if token<>_RKLAMMER then
p1:=sub_expr(opcompare,true,false,p1); p1:=sub_expr(opcompare,[ef_accept_equal],p1);
p1:=caddrnode.create(p1); p1:=caddrnode.create(p1);
got_addrn:=false; got_addrn:=false;
consume(_RKLAMMER); consume(_RKLAMMER);
@ -600,10 +608,10 @@ implementation
message(parser_e_feature_unsupported_for_vm); message(parser_e_feature_unsupported_for_vm);
consume(_LKLAMMER); consume(_LKLAMMER);
got_addrn:=true; got_addrn:=true;
p1:=factor(true,false,false); p1:=factor(true,[]);
{ inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp } { inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp }
if token<>_RKLAMMER then if token<>_RKLAMMER then
p1:=sub_expr(opcompare,true,false,p1); p1:=sub_expr(opcompare,[ef_accept_equal],p1);
p1:=caddrnode.create(p1); p1:=caddrnode.create(p1);
got_addrn:=false; got_addrn:=false;
{ Ofs() returns a cardinal/qword, not a pointer } { Ofs() returns a cardinal/qword, not a pointer }
@ -616,10 +624,10 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
got_addrn:=true; got_addrn:=true;
p1:=factor(true,false,false); p1:=factor(true,[]);
{ inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp } { inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp }
if token<>_RKLAMMER then if token<>_RKLAMMER then
p1:=sub_expr(opcompare,true,false,p1); p1:=sub_expr(opcompare,[ef_accept_equal],p1);
p1:=geninlinenode(in_seg_x,false,p1); p1:=geninlinenode(in_seg_x,false,p1);
got_addrn:=false; got_addrn:=false;
consume(_RKLAMMER); consume(_RKLAMMER);
@ -631,7 +639,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=geninlinenode(l,false,p1); p2:=geninlinenode(l,false,p1);
consume(_RKLAMMER); consume(_RKLAMMER);
statement_syssym:=p2; statement_syssym:=p2;
@ -642,7 +650,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=geninlinenode(l,false,p1); p2:=geninlinenode(l,false,p1);
consume(_RKLAMMER); consume(_RKLAMMER);
statement_syssym:=p2; statement_syssym:=p2;
@ -653,9 +661,9 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
if try_to_consume(_COMMA) then if try_to_consume(_COMMA) then
p2:=ccallparanode.create(comp_expr(true,false),nil) p2:=ccallparanode.create(comp_expr([ef_accept_equal]),nil)
else else
p2:=nil; p2:=nil;
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
@ -670,9 +678,9 @@ implementation
message(parser_e_illegal_slice); message(parser_e_illegal_slice);
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
comp_expr(true,false).free; comp_expr([ef_accept_equal]).free;
if try_to_consume(_COMMA) then if try_to_consume(_COMMA) then
comp_expr(true,false).free; comp_expr([ef_accept_equal]).free;
statement_syssym:=cerrornode.create; statement_syssym:=cerrornode.create;
consume(_RKLAMMER); consume(_RKLAMMER);
end end
@ -680,10 +688,10 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
Consume(_COMMA); Consume(_COMMA);
if not(codegenerror) then if not(codegenerror) then
p2:=ccallparanode.create(comp_expr(true,false),nil) p2:=ccallparanode.create(comp_expr([ef_accept_equal]),nil)
else else
p2:=cerrornode.create; p2:=cerrornode.create;
p2:=ccallparanode.create(p1,p2); p2:=ccallparanode.create(p1,p2);
@ -715,7 +723,7 @@ implementation
type checking } type checking }
p2:=nil; p2:=nil;
repeat repeat
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
if p2<>nil then if p2<>nil then
p2:=caddnode.create(addn,p2,p1) p2:=caddnode.create(addn,p2,p1)
else else
@ -761,7 +769,7 @@ implementation
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
{ don't turn procsyms into calls (getaddr = true) } { don't turn procsyms into calls (getaddr = true) }
p1:=factor(true,false,false); p1:=factor(true,[]);
p2:=geninlinenode(l,false,p1); p2:=geninlinenode(l,false,p1);
consume(_RKLAMMER); consume(_RKLAMMER);
statement_syssym:=p2; statement_syssym:=p2;
@ -777,7 +785,7 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p2:=geninlinenode(l,false,p1); p2:=geninlinenode(l,false,p1);
consume(_RKLAMMER); consume(_RKLAMMER);
statement_syssym:=p2; statement_syssym:=p2;
@ -811,11 +819,11 @@ implementation
Begin Begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args := true; in_args := true;
p1:= ccallparanode.create(comp_expr(true,false), nil); p1:= ccallparanode.create(comp_expr([ef_accept_equal]), nil);
consume(_COMMA); consume(_COMMA);
p2 := ccallparanode.create(comp_expr(true,false),p1); p2 := ccallparanode.create(comp_expr([ef_accept_equal]),p1);
if try_to_consume(_COMMA) then if try_to_consume(_COMMA) then
p2 := ccallparanode.create(comp_expr(true,false),p2); p2 := ccallparanode.create(comp_expr([ef_accept_equal]),p2);
consume(_RKLAMMER); consume(_RKLAMMER);
p2 := geninlinenode(l,false,p2); p2 := geninlinenode(l,false,p2);
statement_syssym := p2; statement_syssym := p2;
@ -826,9 +834,9 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_COMMA); consume(_COMMA);
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,nil))); statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,nil)));
consume(_RKLAMMER); consume(_RKLAMMER);
end; end;
@ -838,11 +846,11 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_COMMA); consume(_COMMA);
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
consume(_COMMA); consume(_COMMA);
paras:=comp_expr(true,false); paras:=comp_expr([ef_accept_equal]);
statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,ccallparanode.create(paras,nil)))); statement_syssym:=geninlinenode(l,false,ccallparanode.create(p1,ccallparanode.create(p2,ccallparanode.create(paras,nil))));
consume(_RKLAMMER); consume(_RKLAMMER);
end; end;
@ -851,9 +859,9 @@ implementation
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
if try_to_consume(_COMMA) then if try_to_consume(_COMMA) then
p2:=comp_expr(true,false) p2:=comp_expr([ef_accept_equal])
else else
begin begin
{ then insert an empty string } { then insert an empty string }
@ -875,7 +883,7 @@ implementation
however, as a stack frame may not exist, it does more harm than however, as a stack frame may not exist, it does more harm than
good, so ignore it.} good, so ignore it.}
in_args:=true; in_args:=true;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
p1.destroy; p1.destroy;
consume(_RKLAMMER); consume(_RKLAMMER);
end; end;
@ -1175,7 +1183,7 @@ implementation
{ read the expression } { read the expression }
if propsym.propdef.typ=procvardef then if propsym.propdef.typ=procvardef then
getprocvardef:=tprocvardef(propsym.propdef); getprocvardef:=tprocvardef(propsym.propdef);
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
if assigned(getprocvardef) then if assigned(getprocvardef) then
handle_procvar(getprocvardef,p2); handle_procvar(getprocvardef,p2);
tcallnode(p1).left:=ccallparanode.create(p2,tcallnode(p1).left); tcallnode(p1).left:=ccallparanode.create(p2,tcallnode(p1).left);
@ -1191,7 +1199,7 @@ implementation
include(p1.flags,nf_isproperty); include(p1.flags,nf_isproperty);
consume(_ASSIGNMENT); consume(_ASSIGNMENT);
{ read the expression } { read the expression }
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
p1:=cassignmentnode.create(p1,p2); p1:=cassignmentnode.create(p1,p2);
end end
else else
@ -1348,7 +1356,7 @@ implementation
p1.free; p1.free;
if try_to_consume(_LKLAMMER) then if try_to_consume(_LKLAMMER) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=ctypeconvnode.create_explicit(p1,ttypesym(sym).typedef); p1:=ctypeconvnode.create_explicit(p1,ttypesym(sym).typedef);
end end
@ -1466,7 +1474,7 @@ implementation
if (not typeonly or is_ordinal(hdef)) and if (not typeonly or is_ordinal(hdef)) and
try_to_consume(_LKLAMMER) then try_to_consume(_LKLAMMER) then
begin begin
result:=comp_expr(true,false); result:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
{ type casts to class helpers aren't allowed } { type casts to class helpers aren't allowed }
if is_objectpascal_helper(hdef) then if is_objectpascal_helper(hdef) then
@ -1684,14 +1692,14 @@ implementation
else if try_to_consume(_LECKKLAMMER) then else if try_to_consume(_LECKKLAMMER) then
begin begin
repeat repeat
comp_expr(true,false); comp_expr([ef_accept_equal]);
until not try_to_consume(_COMMA); until not try_to_consume(_COMMA);
consume(_RECKKLAMMER); consume(_RECKKLAMMER);
end end
else if try_to_consume(_LKLAMMER) then else if try_to_consume(_LKLAMMER) then
begin begin
repeat repeat
comp_expr(true,false); comp_expr([ef_accept_equal]);
until not try_to_consume(_COMMA); until not try_to_consume(_COMMA);
consume(_RKLAMMER); consume(_RKLAMMER);
end end
@ -1722,7 +1730,7 @@ implementation
countindices:=0; countindices:=0;
repeat repeat
p4:=comp_expr(true,false); p4:=comp_expr([ef_accept_equal]);
addstatement(newstatement,cassignmentnode.create( addstatement(newstatement,cassignmentnode.create(
ctemprefnode.create_offset(temp,countindices*s32inttype.size),p4)); ctemprefnode.create_offset(temp,countindices*s32inttype.size),p4));
@ -1738,7 +1746,7 @@ implementation
if token=_ASSIGNMENT then if token=_ASSIGNMENT then
begin begin
consume(_ASSIGNMENT); consume(_ASSIGNMENT);
p4:=comp_expr(true,false); p4:=comp_expr([ef_accept_equal]);
{ create call to fpc_vararray_put } { create call to fpc_vararray_put }
paras:=ccallparanode.create(cordconstnode.create paras:=ccallparanode.create(cordconstnode.create
@ -1805,7 +1813,7 @@ implementation
cvecnode.create( cvecnode.create(
ctemprefnode.create(arrnode), ctemprefnode.create(arrnode),
cordconstnode.create(paracount,arrdef.rangedef,false)), cordconstnode.create(paracount,arrdef.rangedef,false)),
comp_expr(true,false))); comp_expr([ef_accept_equal])));
inc(paracount); inc(paracount);
until not try_to_consume(_COMMA); until not try_to_consume(_COMMA);
consume(_RKLAMMER); consume(_RKLAMMER);
@ -2017,10 +2025,10 @@ implementation
if (tpointerdef(p1.resultdef).pointeddef.typ=arraydef) and if (tpointerdef(p1.resultdef).pointeddef.typ=arraydef) and
(m_autoderef in current_settings.modeswitches) then (m_autoderef in current_settings.modeswitches) then
p1:=cderefnode.create(p1); p1:=cderefnode.create(p1);
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
{ Support Pbytevar[0..9] which returns array [0..9].} { Support Pbytevar[0..9] which returns array [0..9].}
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
p2:=crangenode.create(p2,comp_expr(true,false)); p2:=crangenode.create(p2,comp_expr([ef_accept_equal]));
p1:=cvecnode.create(p1,p2); p1:=cvecnode.create(p1,p2);
end; end;
variantdef: variantdef:
@ -2031,15 +2039,15 @@ implementation
end; end;
stringdef : stringdef :
begin begin
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
{ Support string[0..9] which returns array [0..9] of char.} { Support string[0..9] which returns array [0..9] of char.}
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
p2:=crangenode.create(p2,comp_expr(true,false)); p2:=crangenode.create(p2,comp_expr([ef_accept_equal]));
p1:=cvecnode.create(p1,p2); p1:=cvecnode.create(p1,p2);
end; end;
arraydef: arraydef:
begin begin
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
{ support SEG:OFS for go32v2/msdos Mem[] } { support SEG:OFS for go32v2/msdos Mem[] }
if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16]) and if (target_info.system in [system_i386_go32v2,system_i386_watcom,system_i8086_msdos,system_i8086_win16]) and
(p1.nodetype=loadn) and (p1.nodetype=loadn) and
@ -2055,7 +2063,7 @@ implementation
inserttypeconv(p2,u16inttype); inserttypeconv(p2,u16inttype);
inserttypeconv_internal(p2,u32inttype); inserttypeconv_internal(p2,u32inttype);
p3:=cshlshrnode.create(shln,p2,cordconstnode.create($10,s16inttype,false)); p3:=cshlshrnode.create(shln,p2,cordconstnode.create($10,s16inttype,false));
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
inserttypeconv(p2,u16inttype); inserttypeconv(p2,u16inttype);
inserttypeconv_internal(p2,u32inttype); inserttypeconv_internal(p2,u32inttype);
p2:=caddnode.create(addn,p2,p3); p2:=caddnode.create(addn,p2,p3);
@ -2071,11 +2079,11 @@ implementation
if try_to_consume(_COLON) then if try_to_consume(_COLON) then
begin begin
p3:=caddnode.create(muln,cordconstnode.create($10,s32inttype,false),p2); p3:=caddnode.create(muln,cordconstnode.create($10,s32inttype,false),p2);
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
p2:=caddnode.create(addn,p2,p3); p2:=caddnode.create(addn,p2,p3);
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
{ Support mem[$a000:$0000..$07ff] which returns array [0..$7ff] of memtype.} { Support mem[$a000:$0000..$07ff] which returns array [0..$7ff] of memtype.}
p2:=crangenode.create(p2,caddnode.create(addn,comp_expr(true,false),p3.getcopy)); p2:=crangenode.create(p2,caddnode.create(addn,comp_expr([ef_accept_equal]),p3.getcopy));
p1:=cvecnode.create(p1,p2); p1:=cvecnode.create(p1,p2);
include(tvecnode(p1).flags,nf_memseg); include(tvecnode(p1).flags,nf_memseg);
include(tvecnode(p1).flags,nf_memindex); include(tvecnode(p1).flags,nf_memindex);
@ -2084,7 +2092,7 @@ implementation
begin begin
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
{ Support mem[$80000000..$80000002] which returns array [0..2] of memtype.} { Support mem[$80000000..$80000002] which returns array [0..2] of memtype.}
p2:=crangenode.create(p2,comp_expr(true,false)); p2:=crangenode.create(p2,comp_expr([ef_accept_equal]));
p1:=cvecnode.create(p1,p2); p1:=cvecnode.create(p1,p2);
include(tvecnode(p1).flags,nf_memindex); include(tvecnode(p1).flags,nf_memindex);
end; end;
@ -2096,7 +2104,7 @@ implementation
begin begin
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
{ Support arrayvar[0..9] which returns array [0..9] of arraytype.} { Support arrayvar[0..9] which returns array [0..9] of arraytype.}
p2:=crangenode.create(p2,comp_expr(true,false)); p2:=crangenode.create(p2,comp_expr([ef_accept_equal]));
p1:=cvecnode.create(p1,p2); p1:=cvecnode.create(p1,p2);
end; end;
end; end;
@ -2106,7 +2114,7 @@ implementation
Message(parser_e_invalid_qualifier); Message(parser_e_invalid_qualifier);
p1.destroy; p1.destroy;
p1:=cerrornode.create; p1:=cerrornode.create;
comp_expr(true,false); comp_expr([ef_accept_equal]);
again:=false; again:=false;
end; end;
end; end;
@ -2400,7 +2408,7 @@ implementation
begin begin
consume(_ASSIGNMENT); consume(_ASSIGNMENT);
{ read the expression } { read the expression }
p3:=comp_expr(true,false); p3:=comp_expr([ef_accept_equal]);
{ concat value parameter too } { concat value parameter too }
p2:=ccallparanode.create(p3,p2); p2:=ccallparanode.create(p3,p2);
p1:=translate_disp_call(p1,p2,dct_propput,dispatchstring,0,voidtype); p1:=translate_disp_call(p1,p2,dct_propput,dispatchstring,0,voidtype);
@ -2590,7 +2598,7 @@ implementation
begin begin
if try_to_consume(_LKLAMMER) then if try_to_consume(_LKLAMMER) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=ctypeconvnode.create_explicit(p1,p1.resultdef); p1:=ctypeconvnode.create_explicit(p1,p1.resultdef);
end end
@ -2666,7 +2674,7 @@ implementation
{$maxfpuregisters 0} {$maxfpuregisters 0}
function factor(getaddr,typeonly,hadspecialize:boolean) : tnode; function factor(getaddr:boolean;flags:texprflags) : tnode;
{--------------------------------------------- {---------------------------------------------
Factor_read_id Factor_read_id
@ -2711,7 +2719,7 @@ implementation
p1:=nil; p1:=nil;
allowspecialize:=not (m_delphi in current_settings.modeswitches) and allowspecialize:=not (m_delphi in current_settings.modeswitches) and
not hadspecialize and not (ef_had_specialize in flags) and
(block_type in [bt_type,bt_var_type,bt_const_type]); (block_type in [bt_type,bt_var_type,bt_const_type]);
if allowspecialize and (token=_ID) and (idtoken=_SPECIALIZE) then if allowspecialize and (token=_ID) and (idtoken=_SPECIALIZE) then
begin begin
@ -2719,7 +2727,7 @@ implementation
isspecialize:=true; isspecialize:=true;
end end
else else
isspecialize:=hadspecialize; isspecialize:=ef_had_specialize in flags;
{ first check for identifier } { first check for identifier }
if token<>_ID then if token<>_ID then
@ -2731,7 +2739,7 @@ implementation
end end
else else
begin begin
if typeonly then if ef_type_only in flags then
searchsym_type(pattern,srsym,srsymtable) searchsym_type(pattern,srsym,srsymtable)
else else
searchsym(pattern,srsym,srsymtable); searchsym(pattern,srsym,srsymtable);
@ -2952,7 +2960,7 @@ implementation
if ((hdef=cvarianttype) or (hdef=colevarianttype)) and if ((hdef=cvarianttype) or (hdef=colevarianttype)) and
not(cs_compilesystem in current_settings.moduleswitches) then not(cs_compilesystem in current_settings.moduleswitches) then
current_module.flags:=current_module.flags or uf_uses_variants; current_module.flags:=current_module.flags or uf_uses_variants;
p1:=handle_factor_typenode(hdef,getaddr,again,srsym,typeonly); p1:=handle_factor_typenode(hdef,getaddr,again,srsym,ef_type_only in flags);
end; end;
end; end;
@ -3116,10 +3124,10 @@ implementation
{ nested array constructors are not allowed, see also tests/webtbs/tw17213.pp } { nested array constructors are not allowed, see also tests/webtbs/tw17213.pp }
old_allow_array_constructor:=allow_array_constructor; old_allow_array_constructor:=allow_array_constructor;
allow_array_constructor:=false; allow_array_constructor:=false;
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
begin begin
p2:=comp_expr(true,false); p2:=comp_expr([ef_accept_equal]);
p1:=carrayconstructorrangenode.create(p1,p2); p1:=carrayconstructorrangenode.create(p1,p2);
end; end;
{ insert at the end of the tree, to get the correct order } { insert at the end of the tree, to get the correct order }
@ -3228,7 +3236,7 @@ implementation
dopostfix:=not could_be_generic(idstr); dopostfix:=not could_be_generic(idstr);
end; end;
{ maybe an additional parameter instead of misusing hadspezialize? } { maybe an additional parameter instead of misusing hadspezialize? }
if dopostfix and not hadspecialize then if dopostfix and not (ef_had_specialize in flags) then
updatefpos:=postfixoperators(p1,again,getaddr); updatefpos:=postfixoperators(p1,again,getaddr);
end end
else else
@ -3241,7 +3249,7 @@ implementation
p1:=nil; p1:=nil;
if not(token in [_SEMICOLON,_ELSE,_END]) then if not(token in [_SEMICOLON,_ELSE,_END]) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
if not assigned(current_procinfo) or if not assigned(current_procinfo) or
(current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) or (current_procinfo.procdef.proctypeoption in [potype_constructor,potype_destructor]) or
is_void(current_procinfo.procdef.returndef) then is_void(current_procinfo.procdef.returndef) then
@ -3477,7 +3485,7 @@ implementation
{ STRING can be also a type cast } { STRING can be also a type cast }
if try_to_consume(_LKLAMMER) then if try_to_consume(_LKLAMMER) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=ctypeconvnode.create_explicit(p1,hdef); p1:=ctypeconvnode.create_explicit(p1,hdef);
{ handle postfix operators here e.g. string(a)[10] } { handle postfix operators here e.g. string(a)[10] }
@ -3495,7 +3503,7 @@ implementation
{ FILE can be also a type cast } { FILE can be also a type cast }
if try_to_consume(_LKLAMMER) then if try_to_consume(_LKLAMMER) then
begin begin
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=ctypeconvnode.create_explicit(p1,hdef); p1:=ctypeconvnode.create_explicit(p1,hdef);
{ handle postfix operators here e.g. string(a)[10] } { handle postfix operators here e.g. string(a)[10] }
@ -3559,14 +3567,14 @@ implementation
{ support both @<x> and @(<x>) } { support both @<x> and @(<x>) }
if try_to_consume(_LKLAMMER) then if try_to_consume(_LKLAMMER) then
begin begin
p1:=factor(true,false,false); p1:=factor(true,[]);
{ inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp } { inside parentheses a full expression is allowed, see also tests\webtbs\tb27517.pp }
if token<>_RKLAMMER then if token<>_RKLAMMER then
p1:=sub_expr(opcompare,true,false,p1); p1:=sub_expr(opcompare,[ef_accept_equal],p1);
consume(_RKLAMMER); consume(_RKLAMMER);
end end
else else
p1:=factor(true,false,false); p1:=factor(true,[]);
if token in postfixoperator_tokens then if token in postfixoperator_tokens then
begin begin
again:=true; again:=true;
@ -3588,7 +3596,7 @@ implementation
_LKLAMMER : _LKLAMMER :
begin begin
consume(_LKLAMMER); consume(_LKLAMMER);
p1:=comp_expr(true,false); p1:=comp_expr([ef_accept_equal]);
consume(_RKLAMMER); consume(_RKLAMMER);
{ it's not a good solution { it's not a good solution
but (a+b)^ makes some problems } but (a+b)^ makes some problems }
@ -3609,7 +3617,7 @@ implementation
_PLUS : _PLUS :
begin begin
consume(_PLUS); consume(_PLUS);
p1:=factor(false,false,false); p1:=factor(false,[]);
p1:=cunaryplusnode.create(p1); p1:=cunaryplusnode.create(p1);
end; end;
@ -3621,7 +3629,7 @@ implementation
{ ugly hack, but necessary to be able to parse } { ugly hack, but necessary to be able to parse }
{ -9223372036854775808 as int64 (JM) } { -9223372036854775808 as int64 (JM) }
pattern := '-'+pattern; pattern := '-'+pattern;
p1:=sub_expr(oppower,false,false,nil); p1:=sub_expr(oppower,[],nil);
{ -1 ** 4 should be - (1 ** 4) and not { -1 ** 4 should be - (1 ** 4) and not
(-1) ** 4 (-1) ** 4
This was the reason of tw0869.pp test failure PM } This was the reason of tw0869.pp test failure PM }
@ -3645,9 +3653,9 @@ implementation
else else
begin begin
if m_isolike_unary_minus in current_settings.modeswitches then if m_isolike_unary_minus in current_settings.modeswitches then
p1:=sub_expr(opmultiply,false,false,nil) p1:=sub_expr(opmultiply,[],nil)
else else
p1:=sub_expr(oppower,false,false,nil); p1:=sub_expr(oppower,[],nil);
p1:=cunaryminusnode.create(p1); p1:=cunaryminusnode.create(p1);
end; end;
@ -3656,7 +3664,7 @@ implementation
_OP_NOT : _OP_NOT :
begin begin
consume(_OP_NOT); consume(_OP_NOT);
p1:=factor(false,false,false); p1:=factor(false,[]);
p1:=cnotnode.create(p1); p1:=cnotnode.create(p1);
end; end;
@ -3682,7 +3690,7 @@ implementation
} }
consume(_OBJCPROTOCOL); consume(_OBJCPROTOCOL);
consume(_LKLAMMER); consume(_LKLAMMER);
p1:=factor(false,false,false); p1:=factor(false,[]);
consume(_RKLAMMER); consume(_RKLAMMER);
p1:=cinlinenode.create(in_objc_protocol_x,false,p1); p1:=cinlinenode.create(in_objc_protocol_x,false,p1);
end; end;
@ -3742,7 +3750,7 @@ implementation
{**************************************************************************** {****************************************************************************
Sub_Expr Sub_Expr
****************************************************************************} ****************************************************************************}
function sub_expr(pred_level:Toperator_precedence;accept_equal,typeonly:boolean;factornode:tnode):tnode; function sub_expr(pred_level:Toperator_precedence;flags:texprflags;factornode:tnode):tnode;
{Reads a subexpression while the operators are of the current precedence {Reads a subexpression while the operators are of the current precedence
level, or any higher level. Replaces the old term, simpl_expr and level, or any higher level. Replaces the old term, simpl_expr and
simpl2_expr.} simpl2_expr.}
@ -3945,24 +3953,24 @@ implementation
if pred_level=highest_precedence then if pred_level=highest_precedence then
begin begin
if factornode=nil then if factornode=nil then
p1:=factor(false,typeonly,false) p1:=factor(false,flags)
else else
p1:=factornode; p1:=factornode;
end end
else else
p1:=sub_expr(succ(pred_level),true,typeonly,factornode); p1:=sub_expr(succ(pred_level),flags+[ef_accept_equal],factornode);
repeat repeat
if (token in [NOTOKEN..last_operator]) and if (token in [NOTOKEN..last_operator]) and
(token in operator_levels[pred_level]) and (token in operator_levels[pred_level]) and
((token<>_EQ) or accept_equal) then ((token<>_EQ) or (ef_accept_equal in flags)) then
begin begin
oldt:=token; oldt:=token;
filepos:=current_tokenpos; filepos:=current_tokenpos;
consume(token); consume(token);
if pred_level=highest_precedence then if pred_level=highest_precedence then
p2:=factor(false,false,false) p2:=factor(false,[])
else else
p2:=sub_expr(succ(pred_level),true,typeonly,nil); p2:=sub_expr(succ(pred_level),flags+[ef_accept_equal],nil);
case oldt of case oldt of
_PLUS : _PLUS :
p1:=caddnode.create(addn,p1,p2); p1:=caddnode.create(addn,p1,p2);
@ -4154,14 +4162,14 @@ implementation
end; end;
function comp_expr(accept_equal,typeonly:boolean):tnode; function comp_expr(flags:texprflags):tnode;
var var
oldafterassignment : boolean; oldafterassignment : boolean;
p1 : tnode; p1 : tnode;
begin begin
oldafterassignment:=afterassignment; oldafterassignment:=afterassignment;
afterassignment:=true; afterassignment:=true;
p1:=sub_expr(opcompare,accept_equal,typeonly,nil); p1:=sub_expr(opcompare,flags,nil);
{ get the resultdef for this expression } { get the resultdef for this expression }
if not assigned(p1.resultdef) then if not assigned(p1.resultdef) then
do_typecheckpass(p1); do_typecheckpass(p1);
@ -4180,7 +4188,7 @@ implementation
begin begin
oldafterassignment:=afterassignment; oldafterassignment:=afterassignment;
p1:=sub_expr(opcompare,true,false,nil); p1:=sub_expr(opcompare,[ef_accept_equal],nil);
{ get the resultdef for this expression } { get the resultdef for this expression }
if not assigned(p1.resultdef) and if not assigned(p1.resultdef) and
dotypecheck then dotypecheck then
@ -4193,7 +4201,7 @@ implementation
_POINTPOINT : _POINTPOINT :
begin begin
consume(_POINTPOINT); consume(_POINTPOINT);
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
p1:=crangenode.create(p1,p2); p1:=crangenode.create(p1,p2);
end; end;
_ASSIGNMENT : _ASSIGNMENT :
@ -4201,7 +4209,7 @@ implementation
consume(_ASSIGNMENT); consume(_ASSIGNMENT);
if assigned(p1.resultdef) and (p1.resultdef.typ=procvardef) then if assigned(p1.resultdef) and (p1.resultdef.typ=procvardef) then
getprocvardef:=tprocvardef(p1.resultdef); getprocvardef:=tprocvardef(p1.resultdef);
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
if assigned(getprocvardef) then if assigned(getprocvardef) then
handle_procvar(getprocvardef,p2); handle_procvar(getprocvardef,p2);
getprocvardef:=nil; getprocvardef:=nil;
@ -4210,25 +4218,25 @@ implementation
_PLUSASN : _PLUSASN :
begin begin
consume(_PLUSASN); consume(_PLUSASN);
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
p1:=gen_c_style_operator(addn,p1,p2); p1:=gen_c_style_operator(addn,p1,p2);
end; end;
_MINUSASN : _MINUSASN :
begin begin
consume(_MINUSASN); consume(_MINUSASN);
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
p1:=gen_c_style_operator(subn,p1,p2); p1:=gen_c_style_operator(subn,p1,p2);
end; end;
_STARASN : _STARASN :
begin begin
consume(_STARASN ); consume(_STARASN );
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
p1:=gen_c_style_operator(muln,p1,p2); p1:=gen_c_style_operator(muln,p1,p2);
end; end;
_SLASHASN : _SLASHASN :
begin begin
consume(_SLASHASN ); consume(_SLASHASN );
p2:=sub_expr(opcompare,true,false,nil); p2:=sub_expr(opcompare,[ef_accept_equal],nil);
p1:=gen_c_style_operator(slashn,p1,p2); p1:=gen_c_style_operator(slashn,p1,p2);
end; end;
else else
@ -4251,7 +4259,7 @@ implementation
p:tnode; p:tnode;
begin begin
result:=0; result:=0;
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
if not codegenerror then if not codegenerror then
begin begin
if (p.nodetype<>ordconstn) or if (p.nodetype<>ordconstn) or
@ -4271,7 +4279,7 @@ implementation
p:tnode; p:tnode;
begin begin
get_stringconst:=''; get_stringconst:='';
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
if p.nodetype<>stringconstn then if p.nodetype<>stringconstn then
begin begin
if (p.nodetype=ordconstn) and is_char(p.resultdef) then if (p.nodetype=ordconstn) and is_char(p.resultdef) then

View File

@ -327,7 +327,7 @@ uses
consume(_COMMA); consume(_COMMA);
block_type:=bt_type; block_type:=bt_type;
tmpparampos:=current_filepos; tmpparampos:=current_filepos;
typeparam:=factor(false,true,false); typeparam:=factor(false,[ef_type_only]);
if typeparam.nodetype=typen then if typeparam.nodetype=typen then
begin begin
if tstoreddef(typeparam.resultdef).is_generic and if tstoreddef(typeparam.resultdef).is_generic and
@ -453,7 +453,7 @@ uses
repeat repeat
if not first then if not first then
begin begin
pt2:=factor(false,true,false); pt2:=factor(false,[ef_type_only]);
pt2.free; pt2.free;
end; end;
first:=false; first:=false;

View File

@ -83,7 +83,7 @@ implementation
if target_info.system in systems_managed_vm then if target_info.system in systems_managed_vm then
message(parser_e_feature_unsupported_for_vm); message(parser_e_feature_unsupported_for_vm);
consume(_LKLAMMER); consume(_LKLAMMER);
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
{ calc return type } { calc return type }
if is_new then if is_new then
begin begin
@ -167,7 +167,7 @@ implementation
if is_typeparam(p.resultdef) then if is_typeparam(p.resultdef) then
begin begin
p.free; p.free;
p:=factor(false,false,false); p:=factor(false,[]);
p.free; p.free;
consume(_RKLAMMER); consume(_RKLAMMER);
new_dispose_statement:=cnothingnode.create; new_dispose_statement:=cnothingnode.create;
@ -178,7 +178,7 @@ implementation
begin begin
Message1(type_e_pointer_type_expected,p.resultdef.typename); Message1(type_e_pointer_type_expected,p.resultdef.typename);
p.free; p.free;
p:=factor(false,false,false); p:=factor(false,[]);
p.free; p.free;
consume(_RKLAMMER); consume(_RKLAMMER);
new_dispose_statement:=cerrornode.create; new_dispose_statement:=cerrornode.create;
@ -189,7 +189,7 @@ implementation
begin begin
Message(parser_e_pointer_to_class_expected); Message(parser_e_pointer_to_class_expected);
p.free; p.free;
new_dispose_statement:=factor(false,false,false); new_dispose_statement:=factor(false,[]);
consume_all_until(_RKLAMMER); consume_all_until(_RKLAMMER);
consume(_RKLAMMER); consume(_RKLAMMER);
exit; exit;
@ -199,7 +199,7 @@ implementation
if is_class(classh) then if is_class(classh) then
begin begin
Message(parser_e_no_new_or_dispose_for_classes); Message(parser_e_no_new_or_dispose_for_classes);
new_dispose_statement:=factor(false,false,false); new_dispose_statement:=factor(false,[]);
consume_all_until(_RKLAMMER); consume_all_until(_RKLAMMER);
consume(_RKLAMMER); consume(_RKLAMMER);
exit; exit;
@ -354,7 +354,7 @@ implementation
while (token=_COMMA) and assigned(variantdesc) do while (token=_COMMA) and assigned(variantdesc) do
begin begin
consume(_COMMA); consume(_COMMA);
p2:=factor(false,false,false); p2:=factor(false,[]);
do_typecheckpass(p2); do_typecheckpass(p2);
if p2.nodetype=ordconstn then if p2.nodetype=ordconstn then
begin begin
@ -421,7 +421,7 @@ implementation
if target_info.system in systems_managed_vm then if target_info.system in systems_managed_vm then
message(parser_e_feature_unsupported_for_vm); message(parser_e_feature_unsupported_for_vm);
consume(_LKLAMMER); consume(_LKLAMMER);
p1:=factor(false,false,false); p1:=factor(false,[]);
if p1.nodetype<>typen then if p1.nodetype<>typen then
begin begin
Message(type_e_type_id_expected); Message(type_e_type_id_expected);

View File

@ -71,7 +71,7 @@ implementation
ex,if_a,else_a : tnode; ex,if_a,else_a : tnode;
begin begin
consume(_IF); consume(_IF);
ex:=comp_expr(true,false); ex:=comp_expr([ef_accept_equal]);
consume(_THEN); consume(_THEN);
if not(token in endtokens) then if not(token in endtokens) then
if_a:=statement if_a:=statement
@ -126,7 +126,7 @@ implementation
casenode : tcasenode; casenode : tcasenode;
begin begin
consume(_CASE); consume(_CASE);
caseexpr:=comp_expr(true,false); caseexpr:=comp_expr([ef_accept_equal]);
{ determines result type } { determines result type }
do_typecheckpass(caseexpr); do_typecheckpass(caseexpr);
{ variants must be accepted, but first they must be converted to integer } { variants must be accepted, but first they must be converted to integer }
@ -320,7 +320,7 @@ implementation
consume(_UNTIL); consume(_UNTIL);
first:=cblocknode.create(first); first:=cblocknode.create(first);
p_e:=comp_expr(true,false); p_e:=comp_expr([ef_accept_equal]);
result:=cwhilerepeatnode.create(p_e,first,false,true); result:=cwhilerepeatnode.create(p_e,first,false,true);
end; end;
@ -332,7 +332,7 @@ implementation
begin begin
consume(_WHILE); consume(_WHILE);
p_e:=comp_expr(true,false); p_e:=comp_expr([ef_accept_equal]);
consume(_DO); consume(_DO);
p_a:=statement; p_a:=statement;
result:=cwhilerepeatnode.create(p_e,p_a,true,false); result:=cwhilerepeatnode.create(p_e,p_a,true,false);
@ -462,7 +462,7 @@ implementation
else else
MessagePos(hloopvar.fileinfo,type_e_illegal_count_var); MessagePos(hloopvar.fileinfo,type_e_illegal_count_var);
hfrom:=comp_expr(true,false); hfrom:=comp_expr([ef_accept_equal]);
if try_to_consume(_DOWNTO) then if try_to_consume(_DOWNTO) then
backward:=true backward:=true
@ -472,7 +472,7 @@ implementation
backward:=false; backward:=false;
end; end;
hto:=comp_expr(true,false); hto:=comp_expr([ef_accept_equal]);
consume(_DO); consume(_DO);
{ Check if the constants fit in the range } { Check if the constants fit in the range }
@ -519,7 +519,7 @@ implementation
else else
loopvarsym:=nil; loopvarsym:=nil;
expr:=comp_expr(true,false); expr:=comp_expr([ef_accept_equal]);
consume(_DO); consume(_DO);
@ -541,7 +541,7 @@ implementation
{ parse loop header } { parse loop header }
consume(_FOR); consume(_FOR);
hloopvar:=factor(false,false,false); hloopvar:=factor(false,[]);
valid_for_loopvar(hloopvar,true); valid_for_loopvar(hloopvar,true);
if try_to_consume(_ASSIGNMENT) then if try_to_consume(_ASSIGNMENT) then
@ -604,7 +604,7 @@ implementation
begin begin
calltempnode:=nil; calltempnode:=nil;
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
do_typecheckpass(p); do_typecheckpass(p);
if (p.nodetype=vecn) and if (p.nodetype=vecn) and
@ -830,12 +830,12 @@ implementation
if not(token in endtokens) then if not(token in endtokens) then
begin begin
{ object } { object }
pobj:=comp_expr(true,false); pobj:=comp_expr([ef_accept_equal]);
if try_to_consume(_AT) then if try_to_consume(_AT) then
begin begin
paddr:=comp_expr(true,false); paddr:=comp_expr([ef_accept_equal]);
if try_to_consume(_COMMA) then if try_to_consume(_COMMA) then
pframe:=comp_expr(true,false); pframe:=comp_expr([ef_accept_equal]);
end; end;
end end
else else

View File

@ -1030,11 +1030,11 @@ implementation
if try_parse_structdef_nested_type(def,current_structdef,false) then if try_parse_structdef_nested_type(def,current_structdef,false) then
exit; exit;
{ we can't accept a equal in type } { we can't accept a equal in type }
pt1:=comp_expr(false,true); pt1:=comp_expr([ef_type_only]);
if try_to_consume(_POINTPOINT) then if try_to_consume(_POINTPOINT) then
begin begin
{ get high value of range } { get high value of range }
pt2:=comp_expr(false,false); pt2:=comp_expr([]);
{ make both the same type or give an error. This is not { make both the same type or give an error. This is not
done when both are integer values, because typecasting done when both are integer values, because typecasting
between -3200..3200 will result in a signed-unsigned between -3200..3200 will result in a signed-unsigned
@ -1610,7 +1610,7 @@ implementation
begin begin
oldlocalswitches:=current_settings.localswitches; oldlocalswitches:=current_settings.localswitches;
include(current_settings.localswitches,cs_allow_enum_calc); include(current_settings.localswitches,cs_allow_enum_calc);
p:=comp_expr(true,false); p:=comp_expr([ef_accept_equal]);
current_settings.localswitches:=oldlocalswitches; current_settings.localswitches:=oldlocalswitches;
if (p.nodetype=ordconstn) then if (p.nodetype=ordconstn) then
begin begin