xref: /llvm-project/clang/test/CXX/drs/cwg210.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 #pragma clang diagnostic push
11*ed128c7dSVlad Serebrennikov #pragma clang diagnostic ignored "-Wvariadic-macros"
12*ed128c7dSVlad Serebrennikov #define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
13*ed128c7dSVlad Serebrennikov #pragma clang diagnostic pop
14*ed128c7dSVlad Serebrennikov #endif
15*ed128c7dSVlad Serebrennikov 
16*ed128c7dSVlad Serebrennikov namespace cwg210 { // cwg210: 2.7
17*ed128c7dSVlad Serebrennikov struct B {
18*ed128c7dSVlad Serebrennikov   long i;
19*ed128c7dSVlad Serebrennikov   B();
20*ed128c7dSVlad Serebrennikov   virtual ~B();
21*ed128c7dSVlad Serebrennikov };
22*ed128c7dSVlad Serebrennikov 
23*ed128c7dSVlad Serebrennikov static_assert(sizeof(B) == 16, "");
24*ed128c7dSVlad Serebrennikov 
25*ed128c7dSVlad Serebrennikov struct D : B {
26*ed128c7dSVlad Serebrennikov   long j;
27*ed128c7dSVlad Serebrennikov   D();
28*ed128c7dSVlad Serebrennikov };
29*ed128c7dSVlad Serebrennikov 
30*ed128c7dSVlad Serebrennikov static_assert(sizeof(D) == 24, "");
31*ed128c7dSVlad Serebrennikov 
toss(const B * b)32*ed128c7dSVlad Serebrennikov void toss(const B* b) {
33*ed128c7dSVlad Serebrennikov   throw *b;
34*ed128c7dSVlad Serebrennikov }
35*ed128c7dSVlad Serebrennikov 
36*ed128c7dSVlad Serebrennikov // CHECK-LABEL: define {{.*}} void @cwg210::toss(cwg210::B const*)
37*ed128c7dSVlad Serebrennikov // CHECK:         %[[EXCEPTION:.*]] = call ptr @__cxa_allocate_exception(i64 16)
38*ed128c7dSVlad Serebrennikov // CHECK:         call void @__cxa_throw(ptr %[[EXCEPTION]], ptr @typeinfo for cwg210::B, ptr @cwg210::B::~B())
39*ed128c7dSVlad Serebrennikov // CHECK-LABEL: }
40*ed128c7dSVlad Serebrennikov 
41*ed128c7dSVlad Serebrennikov } // namespace cwg210
42