xref: /llvm-project/clang/test/CXX/drs/cwg193.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
1*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
8*ed128c7dSVlad Serebrennikov 
9*ed128c7dSVlad Serebrennikov #if __cplusplus == 199711L
10*ed128c7dSVlad Serebrennikov #define NOTHROW throw()
11*ed128c7dSVlad Serebrennikov #else
12*ed128c7dSVlad Serebrennikov #define NOTHROW noexcept(true)
13*ed128c7dSVlad Serebrennikov #endif
14*ed128c7dSVlad Serebrennikov 
15*ed128c7dSVlad Serebrennikov namespace cwg193 { // cwg193: 2.7
16*ed128c7dSVlad Serebrennikov struct A {
~Acwg193::A17*ed128c7dSVlad Serebrennikov   ~A() NOTHROW {}
18*ed128c7dSVlad Serebrennikov };
19*ed128c7dSVlad Serebrennikov 
20*ed128c7dSVlad Serebrennikov struct B {
~Bcwg193::B21*ed128c7dSVlad Serebrennikov   ~B() NOTHROW {}
22*ed128c7dSVlad Serebrennikov };
23*ed128c7dSVlad Serebrennikov 
24*ed128c7dSVlad Serebrennikov struct C {
~Ccwg193::C25*ed128c7dSVlad Serebrennikov   ~C() NOTHROW {}
26*ed128c7dSVlad Serebrennikov };
27*ed128c7dSVlad Serebrennikov 
28*ed128c7dSVlad Serebrennikov struct D : A {
29*ed128c7dSVlad Serebrennikov   B b;
~Dcwg193::D30*ed128c7dSVlad Serebrennikov   ~D() NOTHROW { C c; }
31*ed128c7dSVlad Serebrennikov };
32*ed128c7dSVlad Serebrennikov 
foo()33*ed128c7dSVlad Serebrennikov void foo() {
34*ed128c7dSVlad Serebrennikov   D d;
35*ed128c7dSVlad Serebrennikov }
36*ed128c7dSVlad Serebrennikov 
37*ed128c7dSVlad Serebrennikov // skipping over D1 (complete object destructor)
38*ed128c7dSVlad Serebrennikov // CHECK-LABEL: define {{.*}} void @cwg193::D::~D(){{.*}}
39*ed128c7dSVlad Serebrennikov // CHECK-LABEL: define {{.*}} void @cwg193::D::~D(){{.*}}
40*ed128c7dSVlad Serebrennikov // CHECK-NOT:     call void @cwg193::A::~A()
41*ed128c7dSVlad Serebrennikov // CHECK-NOT:     call void @cwg193::B::~B()
42*ed128c7dSVlad Serebrennikov // CHECK:         call void @cwg193::C::~C()
43*ed128c7dSVlad Serebrennikov // CHECK:         call void @cwg193::B::~B()
44*ed128c7dSVlad Serebrennikov // CHECK:         call void @cwg193::A::~A()
45*ed128c7dSVlad Serebrennikov // CHECK-LABEL: }
46*ed128c7dSVlad Serebrennikov } // namespace cwg193
47