File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -3775,6 +3775,13 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
3775
3775
errorDest.phis [0 ]->addIncoming (errorValue, Builder.GetInsertBlock ());
3776
3776
} else {
3777
3777
Builder.emitBlock (typedErrorLoadBB);
3778
+
3779
+ // Create a dummy use of 'errorValue' in the catch BB to workaround an
3780
+ // LLVM miscompile that ends up taking the wrong branch if there are no
3781
+ // uses of 'errorValue' in the catch block.
3782
+ // FIXME: Remove this when the following radar is fixed: rdar://116636601
3783
+ Builder.CreatePtrToInt (errorValue, IGM.IntPtrTy );
3784
+
3778
3785
auto &ti = cast<LoadableTypeInfo>(IGM.getTypeInfo (errorType));
3779
3786
Explosion errorValue;
3780
3787
ti.loadAsTake (*this , getCalleeTypedErrorResultSlot (errorType), errorValue);
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift -module-name=test -enable-experimental-feature TypedThrows %s -o %t/a.out
3
+ // RUN: %target-run %t/a.out | %FileCheck %s
4
+ // REQUIRES: executable_test
5
+
6
+ public enum MyError : Error {
7
+ case a
8
+ case b
9
+ }
10
+
11
+ public func throwing( ) throws ( MyError) -> Int {
12
+ throw MyError . a
13
+ }
14
+
15
+ func wat( ) {
16
+ fatalError ( " this cannot happen " )
17
+ }
18
+
19
+ public func catching( ) {
20
+ do {
21
+ try throwing ( )
22
+ wat ( )
23
+ } catch {
24
+ }
25
+ }
26
+
27
+ catching ( )
28
+ print ( " Works! " )
29
+ // CHECK: Works!
You can’t perform that action at this time.
0 commit comments