aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C54
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C b/gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
new file mode 100644
index 000000000..325617360
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
@@ -0,0 +1,54 @@
+// { dg-do run { target { powerpc64*-*-linux* } } }
+// { dg-options "-fexceptions -fnon-call-exceptions" }
+
+#include <signal.h>
+#include <stdlib.h>
+#include <fenv.h>
+
+#define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R)
+#define GET_CR(R) ({ int tmp; __asm__ __volatile__ ("mfcr %0" : "=r" (tmp)); (tmp >> 4*(7-R)) & 15; })
+
+void sighandler (int signo, siginfo_t * si, void * uc)
+{
+ SET_CR(2, 3);
+ SET_CR(3, 2);
+ SET_CR(4, 1);
+
+ throw 0;
+}
+
+float test (float a, float b) __attribute__ ((__noinline__));
+float test (float a, float b)
+{
+ float x;
+ asm ("mtcrf %1,%2" : "=f" (x) : "n" (1 << (7-3)), "r" (0), "0" (b) : "cr3");
+ return a / x;
+}
+
+int main ()
+{
+ struct sigaction sa;
+ int status;
+
+ sa.sa_sigaction = sighandler;
+ sa.sa_flags = SA_SIGINFO;
+
+ status = sigaction (SIGFPE, & sa, NULL);
+
+ feenableexcept (FE_DIVBYZERO);
+
+ SET_CR(2, 6);
+ SET_CR(3, 9);
+ SET_CR(4, 12);
+
+ try {
+ test (1, 0);
+ }
+ catch (...) {
+ return GET_CR(2) != 6 || GET_CR(3) != 9 || GET_CR(4) != 12;
+ }
+
+ return 1;
+}
+
+