aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/ubsan/undefined-1.c
blob: d1b9ce78771f5fdf68aa46edf1c7290169739466 (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
27
28
29
30
31
32
33
/* { dg-do run } */
/* { dg-options "-fsanitize=undefined" } */

#include <stdio.h>

int
foo (int x, int y)
{
  const int z = 2;
  if (z & 1)
    return x << y;
  return 0;
}

int
bar (int x, int y)
{
  return x + y;
}

int
main (void)
{
  fputs ("UBSAN TEST START\n", stderr);

  foo (3, 2);
  bar (12, 42);

  fputs ("UBSAN TEST END\n", stderr);
  return 0;
}

/* { dg-output "UBSAN TEST START(\n|\r\n|\r)UBSAN TEST END" } */