brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · d33c624 Raw
47 lines · cpp
1// RUN: %clangxx_asan -O2 %s -o %t2// RUN: not %run %t -2 2>&1 | FileCheck --check-prefix=CHECK-m2 %s3// RUN: not %run %t -1 2>&1 | FileCheck --check-prefix=CHECK-m1 %s4// RUN: %run %t 05// RUN: %run %t 86// RUN: not %run %t 9  2>&1 | FileCheck --check-prefix=CHECK-9  %s7// RUN: not %run %t 10 2>&1 | FileCheck --check-prefix=CHECK-10 %s8// RUN: not %run %t 30 2>&1 | FileCheck --check-prefix=CHECK-30 %s9// RUN: not %run %t 31 2>&1 | FileCheck --check-prefix=CHECK-31 %s10// RUN: not %run %t 41 2>&1 | FileCheck --check-prefix=CHECK-41 %s11// RUN: not %run %t 42 2>&1 | FileCheck --check-prefix=CHECK-42 %s12// RUN: not %run %t 62 2>&1 | FileCheck --check-prefix=CHECK-62 %s13// RUN: not %run %t 63 2>&1 | FileCheck --check-prefix=CHECK-63 %s14// RUN: not %run %t 73 2>&1 | FileCheck --check-prefix=CHECK-73 %s15// RUN: not %run %t 74 2>&1 | FileCheck --check-prefix=CHECK-74 %s16// XFAIL: msvc17#include <string.h>18#include <stdio.h>19#include <stdlib.h>20#include <assert.h>21int main(int argc, char **argv) {22  assert(argc >= 2);23  int idx = atoi(argv[1]);24  char AAA[10], BBB[10], CCC[10];25  memset(AAA, 0, sizeof(AAA));26  memset(BBB, 0, sizeof(BBB));27  memset(CCC, 0, sizeof(CCC));28  int res = 0;29  char *p = AAA + idx;30  printf("AAA: %p\ny: %p\nz: %p\np: %p\n", AAA, BBB, CCC, p);31  // make sure BBB and CCC are not removed;32  return *(short*)(p) + BBB[argc % 2] + CCC[argc % 2];33}34// CHECK-m2: 'AAA'{{.*}} <== {{.*}}underflows this variable35// CHECK-m1: 'AAA'{{.*}} <== {{.*}}partially underflows this variable36// CHECK-9:  'AAA'{{.*}} <== {{.*}}partially overflows this variable37// CHECK-10: 'AAA'{{.*}} <== {{.*}}overflows this variable38// CHECK-30: 'BBB'{{.*}} <== {{.*}}underflows this variable39// CHECK-31: 'BBB'{{.*}} <== {{.*}}partially underflows this variable40// CHECK-41: 'BBB'{{.*}} <== {{.*}}partially overflows this variable41// CHECK-42: 'BBB'{{.*}} <== {{.*}}overflows this variable42// CHECK-62: 'CCC'{{.*}} <== {{.*}}underflows this variable43// CHECK-63: 'CCC'{{.*}} <== {{.*}}partially underflows this variable44// CHECK-73: 'CCC'{{.*}} <== {{.*}}partially overflows this variable45// CHECK-74: 'CCC'{{.*}} <== {{.*}}overflows this variable46// REQUIRES: shadow-scale-347