[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg201.cpp
blobb6cf92a1fc7489ad436cedde0e0a3021e6da9c22
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 #define NOTHROW throw()
11 #else
12 #define NOTHROW noexcept(true)
13 #endif
15 namespace cwg201 { // cwg201: 2.8
17 extern void full_expr_fence() NOTHROW;
19 struct A {
20 ~A() NOTHROW {}
23 struct B {
24 B(A) NOTHROW {}
25 ~B() NOTHROW {}
28 void foo() {
29 full_expr_fence();
30 B b = A();
31 full_expr_fence();
34 // CHECK-LABEL: define {{.*}} void @cwg201::foo()
35 // CHECK: call void @cwg201::full_expr_fence()
36 // CHECK: call void @cwg201::B::B(cwg201::A)
37 // CHECK: call void @cwg201::A::~A()
38 // CHECK: call void @cwg201::full_expr_fence()
39 // CHECK: call void @cwg201::B::~B()
40 // CHECK-LABEL: }
42 } // namespace cwg201