[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg650.cpp
blob33ea179986e32b705114aa0c1058a2b677c6795a
1 // RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -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 -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 -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 -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 -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 -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7 // We aren't testing this since C++26 because of P2748R5 "Disallow Binding a Returned Glvalue to a Temporary".
9 #if __cplusplus == 199711L
10 #define NOTHROW throw()
11 #else
12 #define NOTHROW noexcept(true)
13 #endif
15 namespace cwg650 { // cwg650: 2.8
17 struct Q {
18 ~Q() NOTHROW;
21 struct R {
22 ~R() NOTHROW;
25 struct S {
26 ~S() NOTHROW;
29 const S& f() {
30 Q q;
31 return (R(), S());
34 } // namespace cwg650
36 // CHECK-LABEL: define {{.*}} @cwg650::f()()
37 // CHECK: call void @cwg650::S::~S()
38 // CHECK: call void @cwg650::R::~R()
39 // CHECK: call void @cwg650::Q::~Q()
40 // CHECK-LABEL: }