[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / aligned_alloc-alignment.cpp
blobef7f1cb44e60c9010c50d580af4ea27055de5652
1 // RUN: %clangxx %collect_stack_traces -O0 %s -o %t
3 // Alignment is not a power of 2:
4 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 17 2>&1 | FileCheck %s
5 // Size is not a multiple of alignment:
6 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 8 2>&1 | FileCheck %s
7 // Alignment is 0:
8 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 0 2>&1 | FileCheck %s
10 // The same for allocator_may_return_null=1:
11 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
12 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
13 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
15 // REQUIRES: stable-runtime
17 // UNSUPPORTED: android, ubsan
19 #include <assert.h>
20 #include <errno.h>
21 #include <stdio.h>
22 #include <stdlib.h>
24 extern void *aligned_alloc(size_t alignment, size_t size);
26 int main(int argc, char **argv) {
27 assert(argc == 2);
28 const int alignment = atoi(argv[1]);
30 void *p = aligned_alloc(alignment, 100);
31 // CHECK: {{ERROR: .*Sanitizer: invalid alignment requested in aligned_alloc}}
32 // Handle a case when aligned_alloc is aliased by memalign.
33 // CHECK: {{#0 .*}}{{aligned_alloc|memalign}}
34 // CHECK: {{#[12] .*main .*aligned_alloc-alignment.cpp:}}[[@LINE-4]]
35 // CHECK: {{SUMMARY: .*Sanitizer: invalid-aligned-alloc-alignment}}
37 // The NULL pointer is printed differently on different systems, while (long)0
38 // is always the same.
39 fprintf(stderr, "errno: %d, p: %lx\n", errno, (long)p);
40 // CHECK-NULL: errno: 22, p: 0
42 return 0;