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 | // TODO: Investigate |
10 | // XFAIL: msvc |
11 | |
12 | // Test that we encode whether exceptions are supported in an ABI tag to avoid |
13 | // ODR violations when linking TUs that have different values for it. |
14 | |
15 | // RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU1 -fno-exceptions -o %t.tu1.o |
16 | // RUN: %{cxx} %s %{flags} %{compile_flags} -c -DTU2 -fexceptions -o %t.tu2.o |
17 | // RUN: %{cxx} %s %{flags} %{compile_flags} -c -DMAIN -o %t.main.o |
18 | // RUN: %{cxx} %t.tu1.o %t.tu2.o %t.main.o %{flags} %{link_flags} -o %t.exe |
19 | // RUN: %{exec} %t.exe |
20 | |
21 | // -fno-exceptions |
22 | #ifdef TU1 |
23 | # include <__config> |
24 | _LIBCPP_HIDE_FROM_ABI inline int f() { return 1; } |
25 | int tu1() { return f(); } |
26 | #endif // TU1 |
27 | |
28 | // -fexceptions |
29 | #ifdef TU2 |
30 | # include <__config> |
31 | _LIBCPP_HIDE_FROM_ABI inline int f() { return 2; } |
32 | int tu2() { return f(); } |
33 | #endif // TU2 |
34 | |
35 | #ifdef MAIN |
36 | # include <cassert> |
37 | |
38 | int tu1(); |
39 | int tu2(); |
40 | |
41 | int main(int, char**) { |
42 | assert(tu1() == 1); |
43 | assert(tu2() == 2); |
44 | return 0; |
45 | } |
46 | #endif // MAIN |
47 | |