|
@@ -437,23 +437,30 @@ implementation
|
|
|
{ can't hardcode the position of the '$', e.g. on darwin an underscore
|
|
|
is added }
|
|
|
hashedid.id:=copy(defaultname,2,255);
|
|
|
- { the default sym is always part of the current procedure/function }
|
|
|
- srsymtable:=current_procinfo.procdef.localst;
|
|
|
- srsym:=tsym(srsymtable.findwithhash(hashedid));
|
|
|
- if not assigned(srsym) then
|
|
|
+ { in case of a previous error, current_procinfo might not be set
|
|
|
+ so avoid a crash in this case }
|
|
|
+ if assigned(current_procinfo) then
|
|
|
begin
|
|
|
- { no valid default variable found, so create it }
|
|
|
- srsym:=clocalvarsym.create(defaultname,vs_const,def,[]);
|
|
|
- srsymtable.insert(srsym);
|
|
|
- { mark the staticvarsym as typedconst }
|
|
|
- include(tabstractvarsym(srsym).varoptions,vo_is_typed_const);
|
|
|
- include(tabstractvarsym(srsym).varoptions,vo_is_default_var);
|
|
|
- { The variable has a value assigned }
|
|
|
- tabstractvarsym(srsym).varstate:=vs_initialised;
|
|
|
- { the variable can't be placed in a register }
|
|
|
- tabstractvarsym(srsym).varregable:=vr_none;
|
|
|
- end;
|
|
|
- result:=cloadnode.create(srsym,srsymtable);
|
|
|
+ { the default sym is always part of the current procedure/function }
|
|
|
+ srsymtable:=current_procinfo.procdef.localst;
|
|
|
+ srsym:=tsym(srsymtable.findwithhash(hashedid));
|
|
|
+ if not assigned(srsym) then
|
|
|
+ begin
|
|
|
+ { no valid default variable found, so create it }
|
|
|
+ srsym:=clocalvarsym.create(defaultname,vs_const,def,[]);
|
|
|
+ srsymtable.insert(srsym);
|
|
|
+ { mark the staticvarsym as typedconst }
|
|
|
+ include(tabstractvarsym(srsym).varoptions,vo_is_typed_const);
|
|
|
+ include(tabstractvarsym(srsym).varoptions,vo_is_default_var);
|
|
|
+ { The variable has a value assigned }
|
|
|
+ tabstractvarsym(srsym).varstate:=vs_initialised;
|
|
|
+ { the variable can't be placed in a register }
|
|
|
+ tabstractvarsym(srsym).varregable:=vr_none;
|
|
|
+ end;
|
|
|
+ result:=cloadnode.create(srsym,srsymtable);
|
|
|
+ end
|
|
|
+ else
|
|
|
+ result:=cerrornode.create;
|
|
|
end;
|
|
|
|
|
|
var
|