xref: /llvm-project/clang/test/CXX/drs/cwg124.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 cwg124 { // cwg124: 2.7
16 
17 extern void full_expr_fence() NOTHROW;
18 
19 struct A {
Acwg124::A20   A() NOTHROW {}
~Acwg124::A21   ~A() NOTHROW {}
22 };
23 
24 struct B {
Bcwg124::B25   B(A = A()) NOTHROW {}
~Bcwg124::B26   ~B() NOTHROW {}
27 };
28 
f()29 void f() {
30   full_expr_fence();
31   B b[2];
32   full_expr_fence();
33 }
34 
35 // CHECK-LABEL: define {{.*}} void @cwg124::f()()
36 // CHECK:         call void @cwg124::full_expr_fence()
37 // CHECK:         br label %arrayctor.loop
38 // CHECK-LABEL: arrayctor.loop:
39 // CHECK:         call void @cwg124::A::A()
40 // CHECK:         call void @cwg124::B::B(cwg124::A)
41 // CHECK:         call void @cwg124::A::~A()
42 // CHECK:         br {{.*}}, label %arrayctor.cont, label %arrayctor.loop
43 // CHECK-LABEL: arrayctor.cont:
44 // CHECK:         call void @cwg124::full_expr_fence()
45 // CHECK:         br label %arraydestroy.body
46 // CHECK-LABEL: arraydestroy.body:
47 // CHECK:         call void @cwg124::B::~B()
48 // CHECK-LABEL: }
49 
50 
51 } // namespace cwg124
52