aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2013-12-17 18:41:01 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2013-12-17 18:41:01 +0000
commita7caf9054ff997137e2da7df70473abb75a9890b (patch)
tree715f7d6e3864b87753c35ef31bafaa586c0a1d61 /gcc
parent95796c1fa5cabd90536333d87f00b4d4e3c5ab5a (diff)
downloadgcc-a7caf9054ff997137e2da7df70473abb75a9890b.zip
gcc-a7caf9054ff997137e2da7df70473abb75a9890b.tar.gz
gcc-a7caf9054ff997137e2da7df70473abb75a9890b.tar.bz2
Add __int128 test.
From-SVN: r206065
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/ubsan/overflow-int128.c48
2 files changed, 52 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b76e1fc..d0b796c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-17 Marek Polacek <polacek@redhat.com>
+
+ * c-c++-common/ubsan/overflow-int128.c: New test.
+
2013-12-17 Jakub Jelinek <jakub@redhat.com>
PR ipa/58290
diff --git a/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c b/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c
new file mode 100644
index 0000000..3680bd3
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/overflow-int128.c
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-options "-fsanitize=signed-integer-overflow" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
+
+/* 2^127 - 1 */
+#define INT128_MAX (__int128) (((unsigned __int128) 1 << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 1)) - 1)
+#define INT128_MIN (-INT128_MAX - 1)
+
+int
+main (void)
+{
+ volatile __int128 i = INT128_MAX;
+ volatile __int128 j = 1;
+ volatile __int128 k = i + j;
+ k = j + i;
+ i++;
+ j = INT128_MAX - 100;
+ j += (1 << 10);
+
+ j = INT128_MIN;
+ i = -1;
+ k = i + j;
+ k = j + i;
+ j--;
+ j = INT128_MIN + 100;
+ j += -(1 << 10);
+
+ i = INT128_MAX;
+ j = 2;
+ k = i * j;
+
+ i = INT128_MIN;
+ i = -i;
+
+ return 0;
+}
+
+/* { dg-output "signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 1 \\+ 0x7fffffffffffffffffffffffffffffff cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffff9b \\+ 1024 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -1 \\+ 0x80000000000000000000000000000000 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000000 \\+ -1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000000 \\+ -1 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x80000000000000000000000000000064 \\+ -1024 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x7fffffffffffffffffffffffffffffff \\* 2 cannot be represented in type '__int128'(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*negation of 0x80000000000000000000000000000000 cannot be represented in type '__int128'; cast to an unsigned type to negate this value to itself(\n|\r\n|\r)" } */