[Macros] Always parse macro expansions, diagnose later

Always parse macro expansions, regardless of language mode, and
eliminate the fallback path for very, very, very old object literals
like `#Color`. Instead, check for the feature flag for macro
declaration and at macro expansion time, since this is a semantic
restriction.

While here, refactor things so the vast majority of the macro-handling
logic still applies even if the Swift Swift parser is disabled. Only
attempts to expand the macro will fail. This allows us to enable the
macro-diagnostics test everywhere.
This commit is contained in:
Doug Gregor
2022-12-23 23:22:21 -08:00
parent 71ca9c86e6
commit 6bb9cb8b5d
20 changed files with 105 additions and 217 deletions

View File

@@ -11,5 +11,5 @@
public struct MyStruct {}
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: use of unknown directive '#__debug_emit_invalid_swiftinterface_syntax__'
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: no macro named '__debug_emit_invalid_swiftinterface_syntax__'
// CHECK: MyModule.swiftinterface:{{[0-9]+}}:{{[0-9]+}}: error: failed to verify module interface of 'MyModule' due to the errors above; the textual interface may be broken by project issues or a compiler bug