aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c')
-rw-r--r--gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c b/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
new file mode 100644
index 000000000..92c2de81e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/pr60613-2.c
@@ -0,0 +1,36 @@
+/* PR sanitizer/60613 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=undefined" } */
+
+long long y;
+
+__attribute__((noinline, noclone)) long long
+foo (long long x)
+{
+ asm ("");
+ if (x >= 0 || x < -2040)
+ return 23;
+ x += 2040;
+ return x - y;
+}
+
+__attribute__((noinline, noclone)) long long
+bar (long long x)
+{
+ asm ("");
+ return 8LL - x;
+}
+
+int
+main ()
+{
+ y = -__LONG_LONG_MAX__ + 6;
+ if (foo (8 - 2040) != -__LONG_LONG_MAX__)
+ __builtin_abort ();
+ if (bar (-__LONG_LONG_MAX__ + 5) != -__LONG_LONG_MAX__ + 1)
+ __builtin_abort ();
+ return 0;
+}
+
+/* { dg-output "signed integer overflow: 8 \\- -9223372036854775801 cannot be represented in type 'long long int'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 8 \\- -9223372036854775802 cannot be represented in type 'long long int'" } */