[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / windows-seh-EHa-CppCatchDotDotDot.cpp
blob047894c395bb414d630de5fcfbb4fda7e2521c67
1 // RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -S -emit-llvm %s -o - | FileCheck %s
3 // CHECK: define dso_local void @"?crash@@YAXH@Z
4 // CHECK: invoke void @llvm.seh.try.begin()
5 // CHECK: invoke void @llvm.seh.scope.begin()
6 // CHECK: invoke void @llvm.seh.scope.end()
8 // CHECK: %[[dst:[0-9-]+]] = catchswitch within none [label %catch] unwind to caller
9 // CHECK: %[[dst1:[0-9-]+]] = catchpad within %[[dst]] [ptr null, i32 0, ptr null]
10 // CHECK: "funclet"(token %[[dst1]])
12 // CHECK: invoke void @llvm.seh.try.begin()
13 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
14 // CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])
15 // CHECK: invoke void @llvm.seh.try.end()
17 // *****************************************************************************
18 // Abstract: Test CPP catch(...) under SEH -EHa option
20 void printf(...);
21 int volatile *NullPtr = 0;
22 void foo() {
23 *NullPtr = 0;
25 int *pt1, *pt2, *pt3;
26 int g;
27 void crash(int i) {
28 g = i;
29 try {
30 struct A {
31 A() {
32 printf(" in A ctor \n");
33 if (g == 0)
34 *NullPtr = 0;
36 ~A() {
37 printf(" in A dtor \n");
39 } ObjA;
40 if (i == 1)
41 *NullPtr = 0;
42 } catch (...) {
43 printf(" in catch(...) funclet \n");
44 if (i == 1)
45 throw(i);
49 int main() {
50 for (int i = 0; i < 2; i++) {
51 __try {
52 crash(i);
53 } __except (1) {
54 printf(" Test CPP unwind: in except handler i = %d \n", i);
57 return 0;