|
1 | 1 | // RUN: %empty-directory(%t)
|
2 | 2 |
|
3 |
| -// The module should be generated regardless of errors and diagnostic should still be output |
4 |
| -// RUN: %target-swift-frontend -verify -emit-module -o %t/errors.swiftmodule -emit-reference-dependencies-path %t/errors.swiftdeps -emit-dependencies-path %t/errors.d -experimental-allow-module-with-compiler-errors -D ERROR_MODULE -primary-file %s |
| 3 | +// The module should be generated regardless of errors, including .swiftdeps, .d, |
| 4 | +// .swiftsourceinfo, etc. Diagnostics should still be output as well |
| 5 | + |
| 6 | +// RUN: %target-swift-frontend -verify -emit-module -o %t/errors.swiftmodule -emit-module-source-info -emit-module-doc -emit-reference-dependencies-path %t/errors.swiftdeps -emit-dependencies-path %t/errors.d -experimental-allow-module-with-compiler-errors -primary-file %s |
5 | 7 | // RUN: llvm-bcanalyzer %t/errors.swiftmodule | %FileCheck -check-prefix=CHECK-BC %s
|
| 8 | +// RUN: ls %t/errors.swiftdeps %t/errors.d %t/errors.swiftsourceinfo %t/errors.swiftdoc |
6 | 9 | // CHECK-BC-NOT: UnknownCode
|
7 |
| -// RUN: ls %t/errors.swiftdeps |
8 |
| -// RUN: ls %t/errors.d |
9 |
| - |
10 |
| -#if ERROR_MODULE |
11 |
| -public struct ValidStructInvalidMember { |
12 |
| - public var member: String |
13 |
| - public let memberMissingType: undefined // expected-error {{cannot find type 'undefined'}} |
14 |
| - |
15 |
| - public var memberMissingTypeValidSets: undefined { // expected-error {{cannot find type 'undefined'}} |
16 |
| - willSet { |
17 |
| - print("Setting value \(newValue)") |
18 |
| - } |
19 |
| - didSet { |
20 |
| - print("Set value \(oldValue)") |
21 |
| - } |
22 |
| - } |
23 |
| - public var memberInvalidSets: Int { |
24 |
| - willSet { |
25 |
| - undefined // expected-error {{cannot find 'undefined'}} |
26 |
| - } |
27 |
| - didSet { |
28 |
| - undefined // expected-error {{cannot find 'undefined'}} |
29 |
| - } |
30 |
| - } |
31 |
| - |
32 |
| - public lazy var lazyMemberMissingTypeValidBody: undefined = { // expected-error {{cannot find type 'undefined'}} |
33 |
| - return "" |
34 |
| - }() |
35 |
| - public lazy var lazyMemberInvalidBody: String = { |
36 |
| - return undefined // expected-error {{cannot find 'undefined'}} |
37 |
| - }() |
38 |
| - |
39 |
| - public var memberMissingTypeValidGetSets: String { |
40 |
| - get { member } |
41 |
| - set { member = "" } |
42 |
| - } |
43 |
| - public var memberInvalidGetSet: String { |
44 |
| - get { undefined } // expected-error {{cannot find 'undefined'}} |
45 |
| - set { undefined = "" } // expected-error {{cannot find 'undefined'}} |
46 |
| - } |
47 |
| - |
48 |
| - public func funcBadArg(_ arg: undefined? = nil) {} // expected-error {{cannot find type 'undefined'}} |
49 |
| -} |
50 |
| - |
51 |
| -public func validFunc() -> String { "" } |
52 |
| - |
53 |
| -public func invalidFuncBody() -> ValidStructInvalidMember { |
54 |
| - ret // expected-error {{cannot find 'ret'}} |
55 |
| -} |
56 |
| - |
57 |
| -public func invalidFunc() -> undefined {} // expected-error {{cannot find type 'undefined'}} |
58 |
| - |
59 |
| -extension undefined: undefined {} // expected-error {{cannot find type 'undefined'}} |
60 |
| - |
61 |
| -class GenericClass<T> {} |
62 |
| -class InvalidSuperclass: GenericClass<undefined> {} // expected-error {{cannot find type 'undefined'}} |
63 |
| -#endif |
64 |
| - |
65 |
| -// RUN: %target-swift-frontend -emit-module -o %t/validUses.swiftmodule -experimental-allow-module-with-compiler-errors -I%t -D VALID_USES %s 2>&1 | %FileCheck -check-prefix=CHECK-VALID %s |
66 |
| -// RUN: llvm-bcanalyzer %t/validUses.swiftmodule | %FileCheck -check-prefix=CHECK-BC %s |
67 |
| -#if VALID_USES |
68 |
| -import errors |
69 |
| -func test(s: ValidStructInvalidMember) { |
70 |
| - print(s.member) |
71 |
| - print(validFunc()) |
72 |
| - print(invalidFuncBody()) |
73 |
| -} |
74 |
| - |
75 |
| -// Check SIL diagnostics are still output (no reason not to output SIL since |
76 |
| -// there were no errors) |
77 |
| -func other() -> Int {} |
78 |
| -// CHECK-VALID: allow-errors.swift:[[@LINE-1]]:22: error: missing return in a function expected to return 'Int' |
79 |
| -func other2() -> Bool {} |
80 |
| -// CHECK-VALID: allow-errors.swift:[[@LINE-1]]:24: error: missing return in a function expected to return 'Bool' |
81 |
| -#endif |
82 |
| - |
83 |
| -// All invalid uses should have no errors in the file itself, all referenced |
84 |
| -// invalid declarations should have an error elsewhere (but we don't care what |
85 |
| -// that location is) |
86 |
| - |
87 |
| -// RUN: %target-swift-frontend -emit-module -o %t/invalidTopUse.swiftmodule -experimental-allow-module-with-compiler-errors -I%t -D INVALID_TOP_LEVEL_USE %s 2>&1 | %FileCheck -check-prefix=CHECK-INVALID-TOP %s |
88 |
| -// RUN: llvm-bcanalyzer %t/invalidTopUse.swiftmodule | %FileCheck -check-prefix=CHECK-BC %s |
89 |
| -#if INVALID_TOP_LEVEL_USE |
90 |
| -import errors |
91 |
| -func test() { |
92 |
| - invalidFunc() |
93 |
| -} |
94 |
| -// CHECK-INVALID-TOP-NOT: allow-errors.swift:{{.*}} error: |
95 |
| -// CHECK-INVALID-TOP: error: allowing deserialization of error type '<null>' in module 'errors' |
96 |
| -// CHECK-INVALID-TOP: error: allowing deserialization of invalid declaration 'invalidFunc()' (global function) in module 'errors' |
97 |
| -// CHECK-INVALID-TOP-NOT: allow-errors.swift:{{.*}} error: |
98 |
| -#endif |
99 |
| - |
100 |
| -// RUN: %target-swift-frontend -emit-module -o %t/invalidMemberUse.swiftmodule -experimental-allow-module-with-compiler-errors -I%t -D INVALID_MEMBER_USE %s 2>&1 | %FileCheck -check-prefix=CHECK-INVALID-MEMBER %s |
101 |
| -// RUN: llvm-bcanalyzer %t/invalidMemberUse.swiftmodule | %FileCheck -check-prefix=CHECK-BC %s |
102 |
| -#if INVALID_MEMBER_USE |
103 |
| -import errors |
104 |
| -func test(s: ValidStructInvalidMember) { |
105 |
| - print(s.memberMissingType) |
106 |
| -} |
107 |
| -// CHECK-INVALID-MEMBER-NOT: allow-errors.swift:{{.*}} error: |
108 |
| -// CHECK-INVALID-MEMBER: error: allowing deserialization of error type '<null>' in module 'errors' |
109 |
| -// CHECK-INVALID-MEMBER: error: allowing deserialization of invalid declaration '_' (getter) in module 'errors' |
110 |
| -// CHECK-INVALID-MEMBER: error: allowing deserialization of invalid declaration 'memberMissingType' (property) in module 'errors' |
111 |
| -// CHECK-INVALID-MEMBER-NOT: allow-errors.swift:{{.*}} error: |
112 |
| -#endif |
113 | 10 |
|
114 |
| -// RUN: %target-swift-frontend -emit-module -o %t/invalidMethodUse.swiftmodule -experimental-allow-module-with-compiler-errors -I%t -D INVALID_METHOD_USE %s 2>&1 | %FileCheck -check-prefix=CHECK-INVALID-METHOD %s |
115 |
| -// RUN: llvm-bcanalyzer %t/invalidMethodUse.swiftmodule | %FileCheck -check-prefix=CHECK-BC %s |
116 |
| -#if INVALID_METHOD_USE |
117 |
| -import errors |
118 |
| -func test(s: ValidStructInvalidMember) { |
119 |
| - s.funcBadArg() |
120 |
| -} |
121 |
| -// CHECK-INVALID-METHOD-NOT: allow-errors.swift:{{.*}} error: |
122 |
| -// CHECK-INVALID-METHOD: error: allowing deserialization of error type '<null>' in module 'errors' |
123 |
| -// CHECK-INVALID-METHOD: error: allowing deserialization of invalid declaration 'arg' (parameter) in module 'errors' |
124 |
| -// CHECK-INVALID-METHOD: error: allowing deserialization of invalid declaration 'funcBadArg' (instance method) in module 'errors' |
125 |
| -// CHECK-INVALID-METHOD-NOT: allow-errors.swift:{{.*}} error: |
126 |
| -#endif |
| 11 | +public func invalid() -> undefined {} // expected-error {{cannot find type 'undefined'}} |
0 commit comments