xref: /llvm-project/clang/test/CXX/drs/cwg392.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
1*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*ed128c7dSVlad Serebrennikov // 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*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 cwg392 { // cwg392: 2.8
16*ed128c7dSVlad Serebrennikov 
17*ed128c7dSVlad Serebrennikov struct A {
18*ed128c7dSVlad Serebrennikov   operator bool() NOTHROW;
19*ed128c7dSVlad Serebrennikov };
20*ed128c7dSVlad Serebrennikov 
21*ed128c7dSVlad Serebrennikov class C {
22*ed128c7dSVlad Serebrennikov public:
23*ed128c7dSVlad Serebrennikov   C() NOTHROW;
24*ed128c7dSVlad Serebrennikov   ~C() NOTHROW;
get()25*ed128c7dSVlad Serebrennikov   A& get() NOTHROW { return p; }
26*ed128c7dSVlad Serebrennikov private:
27*ed128c7dSVlad Serebrennikov   A p;
28*ed128c7dSVlad Serebrennikov };
29*ed128c7dSVlad Serebrennikov 
f()30*ed128c7dSVlad Serebrennikov void f()
31*ed128c7dSVlad Serebrennikov {
32*ed128c7dSVlad Serebrennikov   if (C().get()) {}
33*ed128c7dSVlad Serebrennikov }
34*ed128c7dSVlad Serebrennikov 
35*ed128c7dSVlad Serebrennikov } // namespace cwg392
36*ed128c7dSVlad Serebrennikov 
37*ed128c7dSVlad Serebrennikov // CHECK-LABEL: define {{.*}} void @cwg392::f()()
38*ed128c7dSVlad Serebrennikov // CHECK:         call {{.*}} i1 @cwg392::A::operator bool()
39*ed128c7dSVlad Serebrennikov // CHECK:         call void @cwg392::C::~C()
40*ed128c7dSVlad Serebrennikov // CHECK-LABEL: }
41