From: Marek Polacek Date: Wed, 11 Feb 2015 20:59:58 +0000 (+0000) Subject: shift-1.C: New test. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b06479fd41cf0460cc28aea063a28f1e8c0d95a3;p=gcc.git shift-1.C: New test. * 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 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 17dc81f0639..c62cc2372e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-02-11 Marek Polacek + + * 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 * 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 index 9e85042b059..00000000000 --- a/gcc/testsuite/c-c++-common/ubsan/shift-5.c +++ /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 index 00000000000..05e049e82ea --- /dev/null +++ b/gcc/testsuite/g++.dg/ubsan/shift-1.C @@ -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 index 00000000000..beb0dbec7fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/ubsan/c-shift-2.c @@ -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; +}