|
24 | 24 | /// Check diagnostics.
|
25 | 25 | // RUN: %target-swift-frontend -typecheck %t/Client.swift -I %t \
|
26 | 26 | // RUN: -package-name pkg -Rmodule-api-import -swift-version 6 -verify
|
| 27 | +// RUN: %target-swift-frontend -typecheck %t/ClientOfClangModules.swift -I %t \ |
| 28 | +// RUN: -package-name pkg -Rmodule-api-import -swift-version 6 -verify |
27 | 29 | // RUN: %target-swift-frontend -typecheck %t/Client_Swift5.swift -I %t \
|
28 | 30 | // RUN: -swift-version 5 -verify
|
29 | 31 |
|
@@ -211,3 +213,63 @@ func implicitlyInternalFunc(a: NotAnAPIType = notAnAPIFunc()) {}
|
211 | 213 |
|
212 | 214 | // For package decls we only remark on types used in signatures, not for inlinable code.
|
213 | 215 | package func packageFunc(a: PackageType = packageFunc()) {} // expected-remark {{struct 'PackageType' is imported via 'ImportUsedInPackage'}}
|
| 216 | + |
| 217 | +/// Tests for imports of clang modules. |
| 218 | +//--- module.modulemap |
| 219 | +module ClangSimpleUnused { |
| 220 | + header "ClangSimpleUnused.h" |
| 221 | +} |
| 222 | +module ClangSimple { |
| 223 | + header "ClangSimple.h" |
| 224 | +} |
| 225 | + |
| 226 | +module ClangSubmodule { |
| 227 | + header "ClangSubmodule.h" |
| 228 | + |
| 229 | + module ClangSubmoduleSubmodule { |
| 230 | + header "ClangSubmoduleSubmodule.h" |
| 231 | + } |
| 232 | +} |
| 233 | + |
| 234 | +module ClangSubmoduleUnused { |
| 235 | + header "ClangSubmoduleUnused.h" |
| 236 | + |
| 237 | + module ClangSubmoduleUnsuedSubmodule { |
| 238 | + header "ClangSubmoduleUnusedSubmodule.h" |
| 239 | + } |
| 240 | +} |
| 241 | + |
| 242 | +module ClangTopModule { |
| 243 | + header "ClangTopModule.h" |
| 244 | + module ClangTopModuleSubmodule { |
| 245 | + header "ClangTopModuleSubmodule.h" |
| 246 | + } |
| 247 | +} |
| 248 | + |
| 249 | +//--- ClangSimpleUnused.h |
| 250 | +//--- ClangSimple.h |
| 251 | +struct ClangSimpleType {}; |
| 252 | + |
| 253 | +//--- ClangSubmodule.h |
| 254 | +//--- ClangSubmoduleSubmodule.h |
| 255 | +struct ClangSubmoduleSubmoduleType {}; |
| 256 | + |
| 257 | +//--- ClangSubmoduleUnused.h |
| 258 | +//--- ClangSubmoduleUnusedSubmodule.h |
| 259 | + |
| 260 | +//--- ClangTopModule.h |
| 261 | +struct ClangTopModuleType {}; |
| 262 | +//--- ClangTopModuleSubmodule.h |
| 263 | + |
| 264 | +//--- ClientOfClangModules.swift |
| 265 | +public import ClangSimple |
| 266 | +public import ClangSimpleUnused // expected-warning {{public import of 'ClangSimpleUnused' was not used in public declarations or inlinable code}} |
| 267 | +public import ClangSubmodule.ClangSubmoduleSubmodule |
| 268 | +public import ClangSubmoduleUnused.ClangSubmoduleUnsuedSubmodule // expected-warning {{public import of 'ClangSubmoduleUnused' was not used in public declarations or inlinable code}} |
| 269 | + |
| 270 | +// Only the top-level module is used, but we can't detect whether the submodule was used or not. |
| 271 | +public import ClangTopModule.ClangTopModuleSubmodule |
| 272 | + |
| 273 | +public func clangUser(a: ClangSimpleType) {} // expected-remark {{struct 'ClangSimpleType' is imported via 'ClangSimple'}} |
| 274 | +public func clangUser(a: ClangSubmoduleSubmoduleType) {} // expected-remark {{struct 'ClangSubmoduleSubmoduleType' is imported via 'ClangSubmodule'}} |
| 275 | +public func clangUser(a: ClangTopModuleType) {} // expected-remark {{struct 'ClangTopModuleType' is imported via 'ClangTopModule'}} |
0 commit comments