shift-1.C: New test.
authorMarek Polacek <polacek@redhat.com>
Wed, 11 Feb 2015 20:59:58 +0000 (20:59 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Wed, 11 Feb 2015 20:59:58 +0000 (20:59 +0000)
* g++.dg/ubsan/shift-1.C: New test.
* gcc.dg/ubsan/c-shift-2.c: New test.
* c-c++-common/ubsan/shift-5.c: Remove file.

From-SVN: r220631

gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/ubsan/shift-5.c [deleted file]
gcc/testsuite/g++.dg/ubsan/shift-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/ubsan/c-shift-2.c [new file with mode: 0644]

index 17dc81f..c62cc23 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-11  Marek Polacek  <polacek@redhat.com>
+
+       * g++.dg/ubsan/shift-1.C: New test.
+       * gcc.dg/ubsan/c-shift-2.c: New test.
+       * c-c++-common/ubsan/shift-5.c: Remove file.
+
 2015-02-11  Alex Velenko  <Alex.Velenko@arm.com>
 
        * gcc.target/aarch64/atomic-op-consume.c (scan-assember-times):
diff --git a/gcc/testsuite/c-c++-common/ubsan/shift-5.c b/gcc/testsuite/c-c++-common/ubsan/shift-5.c
deleted file mode 100644 (file)
index 9e85042..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-fsanitize=shift -w" } */
-/* { dg-shouldfail "ubsan" } */
-
-int
-foo (int x)
-{
-  /* None of the following should pass.  */
-  switch (x)
-    {
-    case 1 >> -1:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 11 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 11 } */
-    case -1 >> -1:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 14 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 14 } */
-    case 1 << -1:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 17 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 17 } */
-    case -1 << -1:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 20 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 20 } */
-      return 1;
-    }
-  return 0;
-}
-
-int
-bar (int x)
-{
-  /* None of the following should pass.  */
-  switch (x)
-    {
-    case -1 >> 200:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 34 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 34 } */
-    case 1 << 200:
-/* { dg-error "case label does not reduce to an integer constant" "" { target c } 37 } */
-/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 37 } */
-      return 1;
-    }
-  return 0;
-}
diff --git a/gcc/testsuite/g++.dg/ubsan/shift-1.C b/gcc/testsuite/g++.dg/ubsan/shift-1.C
new file mode 100644 (file)
index 0000000..05e049e
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=shift -w" } */
+/* { dg-shouldfail "ubsan" } */
+
+int
+foo (int x)
+{
+  /* None of the following should pass.  */
+  switch (x)
+    {
+    case 1 >> -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+    case -1 >> -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+    case 1 << -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+    case -1 << -1: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+      return 1;
+    }
+  return 0;
+}
+
+int
+bar (int x)
+{
+  /* None of the following should pass.  */
+  switch (x)
+    {
+    case -1 >> 200: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+    case 1 << 200: /* { dg-error "is not a constant expression" "" { xfail { *-*-* } } } */
+      return 1;
+    }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/ubsan/c-shift-2.c b/gcc/testsuite/gcc.dg/ubsan/c-shift-2.c
new file mode 100644 (file)
index 0000000..beb0dbe
--- /dev/null
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=shift -w" } */
+/* { dg-shouldfail "ubsan" } */
+
+int
+foo (int x)
+{
+  /* None of the following should pass.  */
+  switch (x)
+    {
+    case 1 >> -1: /* { dg-error "case label does not reduce to an integer constant" } */
+    case -1 >> -1: /* { dg-error "case label does not reduce to an integer constant" } */
+    case 1 << -1: /* { dg-error "case label does not reduce to an integer constant" } */
+    case -1 << -1: /* { dg-error "case label does not reduce to an integer constant" } */
+      return 1;
+    }
+  return 0;
+}
+
+int
+bar (int x)
+{
+  /* None of the following should pass.  */
+  switch (x)
+    {
+    case -1 >> 200: /* { dg-error "case label does not reduce to an integer constant" } */
+    case 1 << 200: /* { dg-error "case label does not reduce to an integer constant" } */
+      return 1;
+    }
+  return 0;
+}