annotate libcxxabi/test/test_exception_address_alignment.pass.cpp @ 192:d7606dcf6fce

Added tag llvm10 for changeset 0572611fdcc8
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 14 Dec 2020 18:01:34 +0900
parents 0572611fdcc8
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 // UNSUPPORTED: no-exceptions
150
anatofuz
parents:
diff changeset
10 // UNSUPPORTED: c++98, c++03
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 // The system unwind.h on OS X provides an incorrectly aligned _Unwind_Exception
anatofuz
parents:
diff changeset
13 // type. That causes these tests to fail. This XFAIL is my best attempt at
anatofuz
parents:
diff changeset
14 // working around this failure.
anatofuz
parents:
diff changeset
15 // XFAIL: darwin && libcxxabi-has-system-unwinder
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 // Test that the address of the exception object is properly aligned as required
anatofuz
parents:
diff changeset
18 // by the relevant ABI
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 #include <cstdint>
anatofuz
parents:
diff changeset
21 #include <cassert>
anatofuz
parents:
diff changeset
22 #include <__cxxabi_config.h>
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 #include <unwind.h>
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 struct __attribute__((aligned)) AlignedType {};
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 // EHABI : 8-byte aligned
anatofuz
parents:
diff changeset
29 // Itanium: Largest supported alignment for the system
anatofuz
parents:
diff changeset
30 #if defined(_LIBCXXABI_ARM_EHABI)
anatofuz
parents:
diff changeset
31 # define EXPECTED_ALIGNMENT 8
anatofuz
parents:
diff changeset
32 #else
anatofuz
parents:
diff changeset
33 # define EXPECTED_ALIGNMENT alignof(AlignedType)
anatofuz
parents:
diff changeset
34 #endif
anatofuz
parents:
diff changeset
35
anatofuz
parents:
diff changeset
36 static_assert(alignof(_Unwind_Exception) == EXPECTED_ALIGNMENT,
anatofuz
parents:
diff changeset
37 "_Unwind_Exception is incorrectly aligned. This test is expected to fail");
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 struct MinAligned { };
anatofuz
parents:
diff changeset
40 static_assert(alignof(MinAligned) == 1 && sizeof(MinAligned) == 1, "");
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 int main() {
anatofuz
parents:
diff changeset
43 for (int i=0; i < 10; ++i) {
anatofuz
parents:
diff changeset
44 try {
anatofuz
parents:
diff changeset
45 throw MinAligned{};
anatofuz
parents:
diff changeset
46 } catch (MinAligned const& ref) {
anatofuz
parents:
diff changeset
47 assert(reinterpret_cast<uintptr_t>(&ref) % EXPECTED_ALIGNMENT == 0);
anatofuz
parents:
diff changeset
48 }
anatofuz
parents:
diff changeset
49 }
anatofuz
parents:
diff changeset
50 }