mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-22 16:49:23 +02:00
* fix calling convention problem when parsing default value before
the semicolon
This commit is contained in:
parent
2824f0b208
commit
51452c1e1b
@ -48,7 +48,7 @@ implementation
|
|||||||
fmodule,
|
fmodule,
|
||||||
{ pass 1 }
|
{ pass 1 }
|
||||||
node,pass_1,
|
node,pass_1,
|
||||||
nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,nmem,nutils,
|
nmat,nadd,ncal,nset,ncnv,ninl,ncon,nld,nflw,nmem,
|
||||||
{ codegen }
|
{ codegen }
|
||||||
ncgutil,
|
ncgutil,
|
||||||
{ parser }
|
{ parser }
|
||||||
@ -660,6 +660,7 @@ implementation
|
|||||||
{ c var }
|
{ c var }
|
||||||
newtype : ttypesym;
|
newtype : ttypesym;
|
||||||
is_dll,
|
is_dll,
|
||||||
|
hasdefaultvalue,
|
||||||
is_gpc_name,is_cdecl,
|
is_gpc_name,is_cdecl,
|
||||||
extern_var,export_var : boolean;
|
extern_var,export_var : boolean;
|
||||||
old_current_object_option : tsymoptions;
|
old_current_object_option : tsymoptions;
|
||||||
@ -748,6 +749,7 @@ implementation
|
|||||||
(tt.def.needs_inittable and not is_class(tt.def)) then
|
(tt.def.needs_inittable and not is_class(tt.def)) then
|
||||||
Message(parser_e_cant_use_inittable_here);
|
Message(parser_e_cant_use_inittable_here);
|
||||||
ignore_equal:=false;
|
ignore_equal:=false;
|
||||||
|
hasdefaultvalue:=false;
|
||||||
symdone:=false;
|
symdone:=false;
|
||||||
if is_gpc_name then
|
if is_gpc_name then
|
||||||
begin
|
begin
|
||||||
@ -851,18 +853,7 @@ implementation
|
|||||||
pt.free;
|
pt.free;
|
||||||
symdone:=true;
|
symdone:=true;
|
||||||
end;
|
end;
|
||||||
{ Records and objects can't have default values }
|
|
||||||
if is_record or is_object then
|
|
||||||
begin
|
|
||||||
{ try to parse the hint directives }
|
|
||||||
dummysymoptions:=[];
|
|
||||||
try_consume_hintdirective(dummysymoptions);
|
|
||||||
{ for a record there doesn't need to be a ; before the END or ) }
|
|
||||||
if not(token in [_END,_RKLAMMER]) then
|
|
||||||
consume(_SEMICOLON);
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
{ Process procvar directives before = and ; }
|
{ Process procvar directives before = and ; }
|
||||||
if (tt.def.deftype=procvardef) and
|
if (tt.def.deftype=procvardef) and
|
||||||
(tt.def.typesym=nil) and
|
(tt.def.typesym=nil) and
|
||||||
@ -879,26 +870,39 @@ implementation
|
|||||||
dummysymoptions:=[];
|
dummysymoptions:=[];
|
||||||
try_consume_hintdirective(dummysymoptions);
|
try_consume_hintdirective(dummysymoptions);
|
||||||
|
|
||||||
{ Handling of Delphi typed const = initialized vars ! }
|
{ Records and objects can't have default values }
|
||||||
{ When should this be rejected ?
|
if is_record or is_object then
|
||||||
- in parasymtable
|
begin
|
||||||
- in record or object
|
{ for a record there doesn't need to be a ; before the END or ) }
|
||||||
- ... (PM) }
|
if not(token in [_END,_RKLAMMER]) then
|
||||||
|
consume(_SEMICOLON);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ Handling of Delphi typed const = initialized vars }
|
||||||
if (token=_EQUAL) and
|
if (token=_EQUAL) and
|
||||||
not(m_tp7 in aktmodeswitches) and
|
not(m_tp7 in aktmodeswitches) and
|
||||||
not(symtablestack.symtabletype in [parasymtable]) and
|
(symtablestack.symtabletype<>parasymtable) then
|
||||||
not is_record and
|
|
||||||
not is_object then
|
|
||||||
begin
|
begin
|
||||||
|
if (tt.def.deftype=procvardef) and
|
||||||
|
(tt.def.typesym=nil) then
|
||||||
|
begin
|
||||||
|
{ Add calling convention for procvar }
|
||||||
|
handle_calling_convention(tprocvardef(tt.def));
|
||||||
|
calc_parast(tprocvardef(tt.def));
|
||||||
|
end;
|
||||||
read_default_value(sc,tt,is_threadvar);
|
read_default_value(sc,tt,is_threadvar);
|
||||||
{ for locals we've created typedconstsym with a different name }
|
{ for locals we've created typedconstsym with a different name }
|
||||||
if symtablestack.symtabletype<>localsymtable then
|
if symtablestack.symtabletype<>localsymtable then
|
||||||
symdone:=true;
|
symdone:=true;
|
||||||
|
hasdefaultvalue:=true;
|
||||||
end;
|
end;
|
||||||
consume(_SEMICOLON);
|
consume(_SEMICOLON);
|
||||||
end;
|
end;
|
||||||
{ Add calling convention for procvars }
|
|
||||||
if (tt.def.deftype=procvardef) and
|
{ Support calling convention for procvars after semicolon }
|
||||||
|
if not(hasdefaultvalue) and
|
||||||
|
(tt.def.deftype=procvardef) and
|
||||||
(tt.def.typesym=nil) then
|
(tt.def.typesym=nil) then
|
||||||
begin
|
begin
|
||||||
{ Parse procvar directives after ; }
|
{ Parse procvar directives after ; }
|
||||||
@ -913,18 +917,19 @@ implementation
|
|||||||
{ Add calling convention for procvar }
|
{ Add calling convention for procvar }
|
||||||
handle_calling_convention(tprocvardef(tt.def));
|
handle_calling_convention(tprocvardef(tt.def));
|
||||||
calc_parast(tprocvardef(tt.def));
|
calc_parast(tprocvardef(tt.def));
|
||||||
{ Handling of Delphi typed const = initialized vars ! }
|
{ Handling of Delphi typed const = initialized vars }
|
||||||
if (token=_EQUAL) and
|
if (token=_EQUAL) and
|
||||||
|
not(is_record or is_object) and
|
||||||
not(m_tp7 in aktmodeswitches) and
|
not(m_tp7 in aktmodeswitches) and
|
||||||
not(symtablestack.symtabletype in [parasymtable]) and
|
(symtablestack.symtabletype<>parasymtable) then
|
||||||
not is_record and
|
|
||||||
not is_object then
|
|
||||||
begin
|
begin
|
||||||
read_default_value(sc,tt,is_threadvar);
|
read_default_value(sc,tt,is_threadvar);
|
||||||
consume(_SEMICOLON);
|
consume(_SEMICOLON);
|
||||||
symdone:=true;
|
symdone:=true;
|
||||||
|
hasdefaultvalue:=true;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Check for variable directives }
|
{ Check for variable directives }
|
||||||
if not symdone and (token=_ID) then
|
if not symdone and (token=_ID) then
|
||||||
begin
|
begin
|
||||||
@ -1172,7 +1177,11 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.72 2004-03-23 22:34:49 peter
|
Revision 1.73 2004-04-11 12:38:16 peter
|
||||||
|
* fix calling convention problem when parsing default value before
|
||||||
|
the semicolon
|
||||||
|
|
||||||
|
Revision 1.72 2004/03/23 22:34:49 peter
|
||||||
* constants ordinals now always have a type assigned
|
* constants ordinals now always have a type assigned
|
||||||
* integer constants have the smallest type, unsigned prefered over
|
* integer constants have the smallest type, unsigned prefered over
|
||||||
signed
|
signed
|
||||||
|
Loading…
Reference in New Issue
Block a user