]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* function.c (requires_stack_frame_p): If the function can throw
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 May 2012 21:35:37 +0000 (21:35 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 12 May 2012 21:35:37 +0000 (21:35 +0000)
non-call exceptions, return true if the insn can throw internally.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187429 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/null_pointer_deref3.adb [new file with mode: 0644]

index 57c9ec10a0040083cb3c4fcf331d82b8679a2e95..355ae3a049e1bf6a07626fdb64c037299c5900b8 100644 (file)
@@ -1,3 +1,8 @@
+2012-05-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * function.c (requires_stack_frame_p): If the function can throw
+       non-call exceptions, return true if the insn can throw internally.
+
 2012-05-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * doc/generic.texi: Rename TYPE_PTRMEM_P to TYPE_PTRDATAMEM_P.
index b5e9011ce23ddda9903b576563f9a66ff28244e9..00c55a16a62a42078055629b5dfe07c5dd57e86c 100644 (file)
@@ -5316,6 +5316,10 @@ requires_stack_frame_p (rtx insn, HARD_REG_SET prologue_used,
   if (CALL_P (insn))
     return !SIBLING_CALL_P (insn);
 
+  /* We need a frame to get the unique CFA expected by the unwinder.  */
+  if (cfun->can_throw_non_call_exceptions && can_throw_internal (insn))
+    return true;
+
   CLEAR_HARD_REG_SET (hardregs);
   for (df_rec = DF_INSN_DEFS (insn); *df_rec; df_rec++)
     {
index 5f5e68922729b986f5ab2a8aa7af4e67dbe3d550..2869ef23e1f55c86dd69ccd6d23ec3fe37c47557 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-12  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/null_pointer_deref3.adb: New test.
+
 2012-05-12  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/49110
diff --git a/gcc/testsuite/gnat.dg/null_pointer_deref3.adb b/gcc/testsuite/gnat.dg/null_pointer_deref3.adb
new file mode 100644 (file)
index 0000000..f92242e
--- /dev/null
@@ -0,0 +1,24 @@
+-- { dg-do run }
+-- { dg-options "-O -gnatp" }
+
+-- This test requires architecture- and OS-specific support code for unwinding
+-- through signal frames (typically located in *-unwind.h) to pass.  Feel free
+-- to disable it if this code hasn't been implemented yet.
+
+procedure Null_Pointer_Deref3 is
+
+   procedure Leaf is
+      type Int_Ptr is access all Integer;
+      function n return Int_Ptr is
+      begin return null; end;
+
+      Data : Int_Ptr := n;
+   begin
+      Data.all := 0;
+   end;
+
+begin
+   Leaf;
+exception
+   when others => null;
+end;