|
@@ -54,6 +54,14 @@ interface
|
|
|
then the parent node is processed again }
|
|
|
pm_postandagain);
|
|
|
|
|
|
+
|
|
|
+ tmhs_flag = (
|
|
|
+ { exceptions (overflow, sigfault etc.) are considered as side effect }
|
|
|
+ mhs_exceptions
|
|
|
+ );
|
|
|
+ tmhs_flags = set of tmhs_flag;
|
|
|
+ pmhs_flags = ^tmhs_flags;
|
|
|
+
|
|
|
foreachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult of object;
|
|
|
staticforeachnodefunction = function(var n: tnode; arg: pointer): foreachnoderesult;
|
|
|
|
|
@@ -117,7 +125,7 @@ interface
|
|
|
function genloadfield(n: tnode; const fieldname: string): tnode;
|
|
|
|
|
|
{ returns true, if the tree given might have side effects }
|
|
|
- function might_have_sideeffects(n : tnode) : boolean;
|
|
|
+ function might_have_sideeffects(n : tnode;const flags : tmhs_flags = []) : boolean;
|
|
|
|
|
|
{ returns true, if n contains nodes which might be conditionally executed }
|
|
|
function has_conditional_nodes(n : tnode) : boolean;
|
|
@@ -1371,13 +1379,19 @@ implementation
|
|
|
in_finalize_x,in_new_x,in_dispose_x,in_exit,in_copy_x,in_initialize_x,in_leave,in_cycle,
|
|
|
in_and_assign_x_y,in_or_assign_x_y,in_xor_assign_x_y,in_sar_assign_x_y,in_shl_assign_x_y,
|
|
|
in_shr_assign_x_y,in_rol_assign_x_y,in_ror_assign_x_y,in_neg_assign_x,in_not_assign_x])
|
|
|
+ ) or
|
|
|
+ ((mhs_exceptions in pmhs_flags(arg)^) and
|
|
|
+ ((n.nodetype in [derefn,vecn]) or
|
|
|
+ ((n.nodetype in [addn,subn,muln,divn,slashn,unaryminusn]) and (n.localswitches*[cs_check_overflow,cs_check_range]<>[]))
|
|
|
+ )
|
|
|
) then
|
|
|
result:=fen_norecurse_true;
|
|
|
end;
|
|
|
|
|
|
- function might_have_sideeffects(n : tnode) : boolean;
|
|
|
+
|
|
|
+ function might_have_sideeffects(n : tnode; const flags : tmhs_flags) : boolean;
|
|
|
begin
|
|
|
- result:=foreachnodestatic(n,@check_for_sideeffect,nil);
|
|
|
+ result:=foreachnodestatic(n,@check_for_sideeffect,@flags);
|
|
|
end;
|
|
|
|
|
|
|