Clang] Fix expansion of response files in -Wp after integrated-cc1 change
[llvm-project.git] / libcxxabi / test / test_exception_address_alignment.pass.cpp
blob16a896fe2f024f729eab9600351edd33943d5cc4
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: libcxxabi-no-exceptions
10 // UNSUPPORTED: c++98, c++03
12 // The system unwind.h on OS X provides an incorrectly aligned _Unwind_Exception
13 // type. That causes these tests to fail. This XFAIL is my best attempt at
14 // working around this failure.
15 // XFAIL: darwin && libcxxabi-has-system-unwinder
17 // Test that the address of the exception object is properly aligned as required
18 // by the relevant ABI
20 #include <cstdint>
21 #include <cassert>
22 #include <__cxxabi_config.h>
24 #include <unwind.h>
26 struct __attribute__((aligned)) AlignedType {};
28 // EHABI : 8-byte aligned
29 // Itanium: Largest supported alignment for the system
30 #if defined(_LIBCXXABI_ARM_EHABI)
31 # define EXPECTED_ALIGNMENT 8
32 #else
33 # define EXPECTED_ALIGNMENT alignof(AlignedType)
34 #endif
36 static_assert(alignof(_Unwind_Exception) == EXPECTED_ALIGNMENT,
37 "_Unwind_Exception is incorrectly aligned. This test is expected to fail");
39 struct MinAligned { };
40 static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
42 int main() {
43 for (int i=0; i < 10; ++i) {
44 try {
45 throw MinAligned{};
46 } catch (MinAligned const& ref) {
47 assert(reinterpret_cast<uintptr_t>(&ref) % EXPECTED_ALIGNMENT == 0);