blob: addef18e05aa84e08a8352072645b273801b2025 [file] [log] [blame]
Akira Hatanaka1089e752017-05-16 15:19:08 +00001//===---------------- exception_object_alignment.pass.cpp -----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// UNSUPPORTED: libcxxabi-no-exceptions
11
12// Check that the pointer __cxa_allocate_exception returns is aligned to the
13// default alignment for the target architecture.
14
15#include <cassert>
16#include <cstdint>
17#include <cxxabi.h>
18#include <type_traits>
19#include <__cxxabi_config.h>
20
21struct S {
22 int a[4];
23} __attribute__((aligned));
24
25int main() {
26#if !defined(_LIBCXXABI_ARM_EHABI)
27 void *p = __cxxabiv1::__cxa_allocate_exception(16);
28 auto i = reinterpret_cast<uintptr_t>(p);
29 auto a = std::alignment_of<S>::value;
30 assert(i % a == 0);
31#endif
32 return 0;
33}