about summary refs log tree commit diff homepage
path: root/test/Feature/OvershiftCheck.c
blob: bb967166af3c5479646662fadaada3a4efb2393c (plain) (blame)
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
// RUN: %llvmgcc %s -emit-llvm -g -O0 -c -o %t.bc
// RUN: %klee -check-overshift %t.bc 2> %t.log
// RUN: grep -c "overshift error" %t.log
// RUN: grep -c "OvershiftCheck.c:19: overshift error" %t.log
// RUN: grep -c "OvershiftCheck.c:23: overshift error" %t.log

/* This test checks that two consecutive potential overshifts
 * are reported as errors.
 */
int main()
{
  unsigned int x=15;
  unsigned int y;
  unsigned int z;
  volatile unsigned int result;

  /* Overshift if y>= sizeof(x) */
  klee_make_symbolic(&y,sizeof(y),"shift_amount1");
  result = x << y;

  /* Overshift is z>= sizeof(x) */
  klee_make_symbolic(&z,sizeof(z),"shift_amount2");
  result = x >> z;

  return 0;
}