summaryrefslogtreecommitdiff
path: root/test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp')
-rw-r--r--test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp b/test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp
new file mode 100644
index 000000000..c0c7b373f
--- /dev/null
+++ b/test/ubsan/TestCases/Pointer/alignment-assumption-blacklist.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang -fsanitize=alignment -fno-sanitize-recover=alignment -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --implicit-check-not=" assumption "
+
+// RUN: rm -f %tmp
+// RUN: echo "[alignment]" >> %tmp
+// RUN: echo "fun:main" >> %tmp
+// RUN: %clang -fsanitize=alignment -fno-sanitize-recover=alignment -fsanitize-blacklist=%tmp -O0 %s -o %t && %run %t 2>&1
+
+#include <stdlib.h>
+
+int main(int argc, char* argv[]) {
+ char *ptr = (char *)malloc(2);
+
+ __builtin_assume_aligned(ptr + 1, 0x8000);
+ // CHECK: {{.*}}alignment-assumption-blacklist.cpp:[[@LINE-1]]:32: runtime error: assumption of 32768 byte alignment for pointer of type 'char *' failed
+ // CHECK: 0x{{.*}}: note: address is {{.*}} aligned, misalignment offset is {{.*}} byte
+
+ free(ptr);
+
+ return 0;
+}