annotate libcxxabi/test/exception_object_alignment.2.pass.cpp @ 150:1d019706d866

LLVM10
author anatofuz
date Thu, 13 Feb 2020 15:10:13 +0900
parents
children 0572611fdcc8
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
anatofuz
parents:
diff changeset
9 // UNSUPPORTED: libcxxabi-no-exceptions
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 // This test checks that the compiler does not make incorrect assumptions
anatofuz
parents:
diff changeset
12 // about the alignment of the exception (only in that specific case, of
anatofuz
parents:
diff changeset
13 // course).
anatofuz
parents:
diff changeset
14 //
anatofuz
parents:
diff changeset
15 // There was a bug where Clang would emit a call to memset assuming a 16-byte
anatofuz
parents:
diff changeset
16 // aligned exception even when back-deploying to older Darwin systems where
anatofuz
parents:
diff changeset
17 // exceptions are 8-byte aligned, which caused a segfault on those systems.
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 struct exception {
anatofuz
parents:
diff changeset
20 exception() : x(0) { }
anatofuz
parents:
diff changeset
21 virtual ~exception() { }
anatofuz
parents:
diff changeset
22 int x;
anatofuz
parents:
diff changeset
23 };
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 struct foo : exception { };
anatofuz
parents:
diff changeset
26
anatofuz
parents:
diff changeset
27 int main() {
anatofuz
parents:
diff changeset
28 try {
anatofuz
parents:
diff changeset
29 throw foo();
anatofuz
parents:
diff changeset
30 } catch (...) {
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 }
anatofuz
parents:
diff changeset
33 return 0;
anatofuz
parents:
diff changeset
34 }