aae9b1ae2fd49c6d7ab442f56e77f4a4d2b39440
[oota-llvm.git] / test / Verifier / invalid-eh.ll
1 ; RUN: sed -e s/.T1:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK1 %s
2 ; RUN: sed -e s/.T2:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK2 %s
3 ; RUN: sed -e s/.T3:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK3 %s
4 ; RUN: sed -e s/.T4:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK4 %s
5 ; RUN: sed -e s/.T5:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s
6 ; RUN: sed -e s/.T6:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s
7 ; RUN: sed -e s/.T7:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK7 %s
8
9 declare void @g()
10
11 ;T1: define void @f() {
12 ;T1:   entry:
13 ;T1:     catchret from undef to label %next
14 ;T1:     ; CHECK1: CatchReturnInst needs to be provided a CatchPad
15 ;T1:   next:
16 ;T1:     unreachable
17 ;T1: }
18
19 ;T2: define void @f() {
20 ;T2:   entry:
21 ;T2:     %x = cleanuppad within none []
22 ;T2:     ; catchret's first operand's operator must be catchpad
23 ;T2:     catchret from %x to label %entry
24 ;T2:     ; CHECK2: CatchReturnInst needs to be provided a CatchPad
25 ;T2: }
26
27 ;T3: define void @f() {
28 ;T3:   entry:
29 ;T3:     cleanupret from undef unwind label %next
30 ;T3:     ; CHECK3: CleanupReturnInst needs to be provided a CleanupPad
31 ;T3:   next:
32 ;T3:     unreachable
33 ;T3: }
34
35 ;T4: define void @f() {
36 ;T4:   entry:
37 ;T4:     %cs = catchswitch within none [label %next] unwind to caller
38 ;T4:   next:
39 ;T4:     %x = catchpad within %cs []
40 ;T4:     ; cleanupret first operand's operator must be cleanuppad
41 ;T4:     cleanupret from %x unwind to caller
42 ;T4:     ; CHECK4: CleanupReturnInst needs to be provided a CleanupPad
43 ;T4: }
44
45 ;T5: define void @f() personality void ()* @g {
46 ;T5:   entry:
47 ;T5:     ret void
48 ;T5:   switch:
49 ;T5:     %cs = catchswitch within none [label %catch] unwind to caller
50 ;T5:   catch:
51 ;T5:     catchpad within %cs []
52 ;T5:     unreachable
53 ;T5:   bogus:
54 ;T5:     cleanuppad within %cs []
55 ;T5:     ; CHECK5: CleanupPadInst has an invalid parent
56 ;T5:     unreachable
57 ;T5: }
58
59 ;T6: define void @f() personality void ()* @g {
60 ;T6:   entry:
61 ;T6:     ret void
62 ;T6:   switch1:
63 ;T6:     %cs1 = catchswitch within none [label %catch1] unwind label %catch2
64 ;T6:     ; CHECK6: Block containg CatchPadInst must be jumped to only by its catchswitch
65 ;T6:   catch1:
66 ;T6:     catchpad within %cs1 []
67 ;T6:     unreachable
68 ;T6:   switch2:
69 ;T6:     %cs2 = catchswitch within none [label %catch2] unwind to caller
70 ;T6:   catch2:
71 ;T6:     catchpad within %cs2 []
72 ;T6:     unreachable
73 ;T6: }
74
75 ;T7: define void @f() personality void ()* @g {
76 ;T7:   entry:
77 ;T7:     ret void
78 ;T7:   switch1:
79 ;T7:     %cs1 = catchswitch within none [label %catch1] unwind to caller
80 ;T7:   catch1:
81 ;T7:     catchpad within %cs1 []
82 ;T7:     unreachable
83 ;T7:   switch2:
84 ;T7:     %cs2 = catchswitch within %cs1 [label %catch2] unwind to caller
85 ;T7:     ; CHECK7: CatchSwitchInst has an invalid parent
86 ;T7:   catch2:
87 ;T7:     catchpad within %cs2 []
88 ;T7:     unreachable
89 ;T7: }