File tree Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Expand file tree Collapse file tree 2 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 1
1
// RUN: %target-swift-frontend -enable-experimental-static-assert -emit-sil %s -verify
2
+ // RUN: %target-swift-frontend -enable-experimental-static-assert -enable-ownership-stripping-after-serialization -emit-sil %s -verify
2
3
3
4
// REQUIRES: optimized_stdlib
4
5
// REQUIRES: asserts
@@ -67,17 +68,6 @@ func test_loops() {
67
68
#assert( infiniteLoop ( ) == 1 )
68
69
}
69
70
70
- func recursive( a: Int ) -> Int {
71
- // expected-note@+1 {{limit exceeded here}}
72
- return a == 0 ? 0 : recursive ( a: a- 1 )
73
- }
74
-
75
- func test_recursive( ) {
76
- // expected-error @+2 {{#assert condition not constant}}
77
- // expected-note @+1 {{exceeded instruction limit: 512 when evaluating the expression at compile time}}
78
- #assert( recursive ( a: 20000 ) > 42 )
79
- }
80
-
81
71
func conditional( _ x: Int ) -> Int {
82
72
if x < 0 {
83
73
return 0
Original file line number Diff line number Diff line change
1
+ // RUN: not %target-swift-frontend -enable-experimental-static-assert -emit-sil %s 2>&1 | %FileCheck %s
2
+ // RUN: not %target-swift-frontend -enable-experimental-static-assert -enable-ownership-stripping-after-serialization -emit-sil %s 2>&1 | %FileCheck %s
3
+
4
+ // This is a special FileCheck test for testing that we properly catch that we
5
+ // are recursing here. The reason why this is separate from the other
6
+ // pound_assert tests is that the "limit exceeded" here diagnostic can vary
7
+ // depending on the codegen since we are using an arbitrary limit of 512. If the
8
+ // codegen changes, the line where we stop evaluating can change meaning that
9
+ // the note moves around lines. With FileCheck we have more flexibility to just
10
+ // match what we actually want.
11
+
12
+ // CHECK: error: #assert condition not constant
13
+ // CHECK: note: exceeded instruction limit: 512 when evaluating the expression at compile time
14
+ // CHECK: limit exceeded here
15
+ func recursive( a: Int ) -> Int {
16
+ return a == 0 ? 0 : recursive ( a: a- 1 )
17
+ }
18
+
19
+ func test_recursive( ) {
20
+ #assert( recursive ( a: 20000 ) > 42 )
21
+ }
22
+
You can’t perform that action at this time.
0 commit comments