Files
clang-p2996/compiler-rt/test/ubsan/TestCases/Pointer/align-assume-attribute-alloc_align-on-function.cpp
Roy Sundahl f9450807dd [ubsan][test] Fix typo in D139230
Fix "runtime runtime error" -> "runtime error"

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D140321
2023-01-06 14:28:07 -08:00

30 lines
2.1 KiB
C++

// RUN: %clang -x c -fsanitize=alignment -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c -fsanitize=alignment -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c -fsanitize=alignment -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c -fsanitize=alignment -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c++ -fsanitize=alignment -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c++ -fsanitize=alignment -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c++ -fsanitize=alignment -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
// RUN: %clang -x c++ -fsanitize=alignment -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption " --implicit-check-not="note:" --implicit-check-not="runtime error:"
#include <stdlib.h>
char *__attribute__((alloc_align(2)))
passthrough(char *x, unsigned long alignment) {
return x;
}
int main(int argc, char* argv[]) {
char *ptr = (char *)malloc(2);
passthrough(ptr + 1, 0x8000);
// CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-1]]:3: runtime error: assumption of 32768 byte alignment for pointer of type 'char *' failed
// CHECK: {{.*}}align-assume-{{.*}}.cpp:[[@LINE-10]]:22: note: alignment assumption was specified here
// CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is {{.*}} byte
free(ptr);
return 0;
}