|
1 | 1 | // REQUIRES: swift_swift_parser, executable_test |
| 2 | +// REQUIRES: swift_feature_ABIAttribute |
2 | 3 |
|
3 | 4 | // For _Concurrency. |
4 | 5 | // UNSUPPORTED: use_os_stdlib |
5 | 6 | // UNSUPPORTED: back_deployment_runtime |
6 | 7 |
|
7 | 8 | // RUN: %empty-directory(%t) |
8 | 9 | // RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -parse-as-library -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath |
9 | | -// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -disable-availability-checking -DTEST_DIAGNOSTICS |
| 10 | +// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -disable-availability-checking -enable-experimental-feature ABIAttribute -DTEST_DIAGNOSTICS |
10 | 11 |
|
11 | 12 | // Check with the imported macro library vs. the local declaration of the macro. |
12 | 13 | // RUN: %target-swift-frontend -swift-version 5 -emit-module -o %t/macro_library.swiftmodule %S/Inputs/macro_library.swift -module-name macro_library -load-plugin-library %t/%target-library-name(MacroDefinition) |
13 | 14 |
|
14 | | -// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -disable-availability-checking -DIMPORT_MACRO_LIBRARY -I %t -DTEST_DIAGNOSTICS |
| 15 | +// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library -disable-availability-checking -DIMPORT_MACRO_LIBRARY -I %t -enable-experimental-feature ABIAttribute -DTEST_DIAGNOSTICS |
15 | 16 |
|
16 | 17 |
|
17 | 18 | // RUN: %target-swift-frontend -swift-version 5 -typecheck -load-plugin-library %t/%target-library-name(MacroDefinition) -parse-as-library %s -disable-availability-checking -dump-macro-expansions > %t/expansions-dump.txt 2>&1 |
@@ -309,3 +310,26 @@ func closuresInPeerMacroCrash() {} |
309 | 310 | @trait(Trait {}) |
310 | 311 | @trait(Trait {}) |
311 | 312 | var closuresInPeerMacroOnVariableCrash: Int = 0 |
| 313 | + |
| 314 | +// Test that macros can't be used in @abi |
| 315 | + |
| 316 | +#if swift(>=5.3) && TEST_DIAGNOSTICS |
| 317 | +struct ABIAttrWithAttachedMacro { |
| 318 | + // expected-error@+1 {{macro 'addCompletionHandler()' cannot be expanded in '@abi' attribute}} |
| 319 | + @abi(@addCompletionHandler func fn1() async) |
| 320 | + @addCompletionHandler func fn1() async {} |
| 321 | + // From diagnostics in the expansion: |
| 322 | + // expected-note@-2 3{{in expansion of macro 'addCompletionHandler' on instance method 'fn1()' here}} |
| 323 | + // expected-note@-4 {{'fn1()' previously declared here}} |
| 324 | + |
| 325 | + // expected-error@+1 {{macro 'addCompletionHandler()' cannot be expanded in '@abi' attribute}} |
| 326 | + @abi(@addCompletionHandler func fn2() async) |
| 327 | + func fn2() async {} |
| 328 | + |
| 329 | + @abi(func fn3() async) |
| 330 | + @addCompletionHandler func fn3() async {} |
| 331 | + // From diagnostics in the expansion: |
| 332 | + // expected-note@-2 2{{in expansion of macro 'addCompletionHandler' on instance method 'fn3()' here}} |
| 333 | + // expected-note@-4 {{'fn3()' previously declared here}} |
| 334 | +} |
| 335 | +#endif |
0 commit comments