Make test more lenient for custom clang version strings
[llvm-project.git] / compiler-rt / test / asan / TestCases / invalid-pointer-pairs-subtract-errors.cpp
blob535833d05c89a6bfd8c8bfe752bf60af0a4b3fbe
1 // RUN: %clangxx_asan -O0 %s -o %t -mllvm -asan-detect-invalid-pointer-pair
3 // RUN: %env_asan_opts=detect_invalid_pointer_pairs=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s
5 #include <assert.h>
6 #include <stdlib.h>
8 int foo(char *p, char *q) {
9 return p - q;
12 char global1[100] = {}, global2[100] = {};
14 int main() {
15 // Heap allocated memory.
16 char *heap1 = (char *)malloc(42);
17 char *heap2 = (char *)malloc(42);
19 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
20 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
21 foo(heap1, heap2);
23 // Global variables.
24 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
25 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
26 foo(&global1[0], &global2[10]);
28 // Stack variables.
29 char stack1, stack2;
30 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
31 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
32 foo(&stack1, &stack2);
34 // Mixtures.
35 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
36 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
37 foo(heap1, &stack1);
38 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
39 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
40 foo(heap1, &global1[0]);
41 // CHECK: ERROR: AddressSanitizer: invalid-pointer-pair
42 // CHECK: #{{[0-9]+ .*}} in main {{.*}}invalid-pointer-pairs-subtract-errors.cpp:[[@LINE+1]]
43 foo(&stack1, &global1[0]);
45 free(heap1);
46 free(heap2);
47 return 0;