xref: /llvm-project/clang/test/CXX/drs/cwg201.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
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
8 
9 #if __cplusplus == 199711L
10 #define NOTHROW throw()
11 #else
12 #define NOTHROW noexcept(true)
13 #endif
14 
15 namespace cwg201 { // cwg201: 2.8
16 
17 extern void full_expr_fence() NOTHROW;
18 
19 struct A {
~Acwg201::A20   ~A() NOTHROW {}
21 };
22 
23 struct B {
Bcwg201::B24   B(A) NOTHROW {}
~Bcwg201::B25   ~B() NOTHROW {}
26 };
27 
foo()28 void foo() {
29   full_expr_fence();
30   B b = A();
31   full_expr_fence();
32 }
33 
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: }
41 
42 } // namespace cwg201
43