Explorar o código

* might_have_sideeffects takes care of absolute

git-svn-id: trunk@44083 -
florian %!s(int64=5) %!d(string=hai) anos
pai
achega
d479069f8c
Modificáronse 4 ficheiros con 40 adicións e 0 borrados
  1. 2 0
      .gitattributes
  2. 2 0
      compiler/nutils.pas
  3. 18 0
      tests/test/tabsvr6.pp
  4. 18 0
      tests/test/tabsvr7.pp

+ 2 - 0
.gitattributes

@@ -14062,6 +14062,8 @@ tests/test/tabsvr2.pp svneol=native#text/plain
 tests/test/tabsvr3.pp svneol=native#text/plain
 tests/test/tabsvr4.pp svneol=native#text/plain
 tests/test/tabsvr5.pp svneol=native#text/plain
+tests/test/tabsvr6.pp svneol=native#text/pascal
+tests/test/tabsvr7.pp svneol=native#text/pascal
 tests/test/taddstr1.pp svneol=native#text/plain
 tests/test/taes1.pp svneol=native#text/plain
 tests/test/talign.pp svneol=native#text/plain

+ 2 - 0
compiler/nutils.pas

@@ -1403,6 +1403,8 @@ implementation
             ((n.nodetype in [derefn,vecn,subscriptn]) or
              ((n.nodetype in [addn,subn,muln,divn,slashn,unaryminusn]) and (n.localswitches*[cs_check_overflow,cs_check_range]<>[]))
             )
+           ) or
+           ((n.nodetype=loadn) and (tloadnode(n).symtableentry.typ=absolutevarsym) and (tabsolutevarsym(tloadnode(n).symtableentry).abstyp=toaddr)
            ) then
           result:=fen_norecurse_true;
       end;

+ 18 - 0
tests/test/tabsvr6.pp

@@ -0,0 +1,18 @@
+{$mode objfpc}
+{$B+}
+uses
+  sysutils;
+var
+  { absolute means volatile, so the expression below cannot be optimized 
+    and must cause a sig fault }
+  a : longint absolute 0;  
+begin
+  try
+    while true or (a=0) do
+      break;
+  except
+    writeln('ok');
+    halt(0);
+  end;
+  halt(1);
+end.

+ 18 - 0
tests/test/tabsvr7.pp

@@ -0,0 +1,18 @@
+{$mode objfpc}
+{$B+}
+uses
+  sysutils;
+var
+  { absolute means volatile, so the expression below cannot be optimized 
+    and must cause a sig fault }
+  a : longint absolute 0;  
+begin
+  try
+    while false and (a=0) do
+      break;
+  except
+    writeln('ok');
+    halt(0);
+  end;
+  halt(1);
+end.