[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg210.cpp
blob2c3cf61a6a5b1a16b3274677f18fa84b28c98880
1 // RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2 // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3 // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7 // RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
9 #if __cplusplus == 199711L
10 #pragma clang diagnostic push
11 #pragma clang diagnostic ignored "-Wvariadic-macros"
12 #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
13 #pragma clang diagnostic pop
14 #endif
16 namespace cwg210 { // cwg210: 2.7
17 struct B {
18 long i;
19 B();
20 virtual ~B();
23 static_assert(sizeof(B) == 16, "");
25 struct D : B {
26 long j;
27 D();
30 static_assert(sizeof(D) == 24, "");
32 void toss(const B* b) {
33 throw *b;
36 // CHECK-LABEL: define {{.*}} void @cwg210::toss(cwg210::B const*)
37 // CHECK: %[[EXCEPTION:.*]] = call ptr @__cxa_allocate_exception(i64 16)
38 // CHECK: call void @__cxa_throw(ptr %[[EXCEPTION]], ptr @typeinfo for cwg210::B, ptr @cwg210::B::~B())
39 // CHECK-LABEL: }
41 } // namespace cwg210