// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: compiler-rt-optimized
// UNSUPPORTED: android

#include <string.h>
int main(int argc, char **argv) {
  char a1[] = {static_cast<char>(argc), 2, 3, 4};
  char a2[] = {1, static_cast<char>(2 * argc), 3, 4};
  int res = bcmp(a1, a2, 4 + argc); // BOOM
  // CHECK: AddressSanitizer: stack-buffer-overflow
  // CHECK: {{#1.*bcmp}}
  // CHECK: {{#2.*main}}
  return res;
}

// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s

// REQUIRES: compiler-rt-optimized
// UNSUPPORTED: android
// XFAIL: darwin

#include <string.h>
int main(int argc, char **argv) {
  char a1[] = {static_cast<char>(argc), 2, 3, 4};
  char a2[] = {1, static_cast<char>(2 * argc), 3, 4};
  int res = bcmp(a1, a2, 4 + argc); // BOOM
  // CHECK: AddressSanitizer: stack-buffer-overflow
  // CHECK: {{#1.*bcmp}}
  // CHECK: {{#2.*main}}
  return res;
}

Disable failing test on darwin during investigation.
[compiler-rt] Disable failing test on darwin during investigation.

/Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/projects/compiler-rt/test/asan/TestCases/Posix/bcmp_test.cc:14:12: error: CHECK: expected string not found in input
 // CHECK: {{#1.*bcmp}}
           ^
<stdin>:2:57: note: scanning from here
==34677==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffee93777c4 at pc 0x0001068a7285 bp 0x7ffee9377770 sp 0x7ffee9376ef8
                                                        ^
<stdin>:6:20: note: possible intended match here
 #2 0x106888e77 in main bcmp_test.cc:12
                   ^

git-svn-id: c199f293c43da69278bea8e88f92242bf3aa95f7@354888 91177308-0d34-0410-b5e6-96231b3b80d8
