aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/undefined-2.c
blob: fd5b4d3e9e074e7bd19683eb5109238b9965e5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* { dg-do run } */
/* { dg-options "-fsanitize=undefined" } */
/* { dg-additional-options "-std=gnu11" { target c } } */
/* { dg-additional-options "-std=c++11" { target c++ } } */

#include <stdio.h>

volatile int w, z;

__attribute__ ((noinline, noclone)) int
foo (int x, int y)
{
  z++;
  return x << y;
}

int
main ()
{
  fputs ("1st\n", stderr);
  w = foo (0, -__INT_MAX__);
  return 0;
}

/* { dg-output "1st(\n|\r\n|\r)" } */
/* { dg-output "\[^\n\r]*shift exponent -\[^\n\r]* is negative\[^\n\r]*(\n|\r\n|\r)" } */