On Feb 11, 2015, at 4:24 AM, Marek Polacek <[email protected]> wrote:
>
> The following patch splits the test into C and C++ test cases, so
> hopefully fixing the issue. Ok for trunk?
>
> 2015-02-11 Marek Polacek <[email protected]>
>
> * 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.
>
> diff --git gcc/testsuite/g++.dg/ubsan/shift-1.C
> gcc/testsuite/g++.dg/ubsan/shift-1.C
> index e69de29..8a71279 100644
> --- gcc/testsuite/g++.dg/ubsan/shift-1.C
> +++ gcc/testsuite/g++.dg/ubsan/shift-1.C
> @@ -0,0 +1,37 @@
> +/* { 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 { *-*-* } } 11 } */
Never include line numbers, unless there is no other way. Here, I think you
can drop it, and merely ensure this is on the right line?
An example from gcc.dg:
int g2(int a; __attribute__((unused))); /* { dg-error "just a forward
declaration" "no parms" { xfail *-*-* } } */
I’m hoping that style will work.
> + case -1 >> -1:
> +/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 13 } */
Likewise.
> + case 1 << -1:
> +/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 15 } */
Likewise.
> + case -1 << -1:
> +/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 17 } */
Likewise.
> + 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 { *-*-* } } 30 } */
Likewise.
> + case 1 << 200:
> +/* { dg-error "is not a constant expression" "" { xfail { *-*-* } } 32 } */
Likewise.
Ok with the above fixes, if applicable.