1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: no-exceptions |
10 | |
11 | // The situation for the alignment of exception objects is badly messed up |
12 | // before macOS 10.14. The test fails on macOS 10.9 to 10.12, passes on macOS |
13 | // 10.13 (no investigation done), and passes afterwards. Just mark all the OSes |
14 | // before 10.14 as unsupported. |
15 | // UNSUPPORTED: stdlib=apple-libc++ && target={{.+}}-apple-macosx10.{{9|10|11|12|13}} |
16 | |
17 | // Check that the pointer __cxa_allocate_exception returns is aligned to the |
18 | // default alignment for the target architecture. |
19 | |
20 | #include <cassert> |
21 | #include <cstdint> |
22 | #include <cxxabi.h> |
23 | #include <type_traits> |
24 | #include <__cxxabi_config.h> |
25 | |
26 | struct S { |
27 | int a[4]; |
28 | } __attribute__((aligned)); |
29 | |
30 | int main(int, char**) { |
31 | #if !defined(_LIBCXXABI_ARM_EHABI) |
32 | void *p = __cxxabiv1::__cxa_allocate_exception(16); |
33 | auto i = reinterpret_cast<uintptr_t>(p); |
34 | auto a = std::alignment_of<S>::value; |
35 | assert(i % a == 0); |
36 | __cxxabiv1::__cxa_free_exception(p); |
37 | #endif |
38 | return 0; |
39 | } |
40 | |