mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -219,6 +219,8 @@ ERROR(unknown_attribute,none,
|
||||
//------------------------------------------------------------------------------
|
||||
NOTE(in_macro_expansion,none,
|
||||
"in expansion of macro %0 here", (DeclName))
|
||||
ERROR(macro_experimental,none,
|
||||
"macros are an experimental feature that is not enabled", ())
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: bridged diagnostics
|
||||
|
||||
@@ -1329,9 +1329,6 @@ ERROR(expected_rsquare_array_expr,PointsToFirstBadToken,
|
||||
// Object literal expressions
|
||||
ERROR(expected_arg_list_in_object_literal,PointsToFirstBadToken,
|
||||
"expected argument list in object literal", ())
|
||||
ERROR(legacy_object_literal,none,
|
||||
"'%select{|[}0#%1(...)%select{|#]}0' has been renamed to '#%2(...)'",
|
||||
(bool, StringRef, StringRef))
|
||||
|
||||
// Unknown pound expression.
|
||||
ERROR(unknown_pound_expr,none,
|
||||
|
||||
@@ -6762,8 +6762,7 @@ ERROR(experimental_no_metadata_feature_can_only_be_used_when_enabled,
|
||||
ERROR(expected_macro_expansion_expr,PointsToFirstBadToken,
|
||||
"expected macro expansion to produce an expression", ())
|
||||
ERROR(macro_undefined,PointsToFirstBadToken,
|
||||
"macro %0 is undefined; use `-load-plugin-library` to specify dynamic "
|
||||
"libraries that contain this macro", (Identifier))
|
||||
"no macro named %0", (Identifier))
|
||||
ERROR(external_macro_not_found,none,
|
||||
"external macro implementation type '%0.%1' could not be found for "
|
||||
"macro %2; the type must be public and provided via "
|
||||
@@ -6798,6 +6797,8 @@ ERROR(macro_expansion_missing_pound,none,
|
||||
"expansion of macro %0 requires leading '#'", (DeclName))
|
||||
ERROR(macro_expansion_missing_arguments,none,
|
||||
"expansion of macro %0 requires arguments", (DeclName))
|
||||
ERROR(macro_unsupported,none,
|
||||
"macros are not supported in this compiler", ())
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// MARK: Move Only Errors
|
||||
|
||||
@@ -1748,7 +1748,6 @@ public:
|
||||
ParserResult<Expr> parseExprMacroExpansion(bool isExprBasic);
|
||||
ParserResult<Expr> parseExprCollection();
|
||||
ParserResult<Expr> parseExprCollectionElement(Optional<bool> &isDictionary);
|
||||
ParserResult<Expr> parseExprPoundUnknown(SourceLoc LSquareLoc);
|
||||
ParserResult<Expr>
|
||||
parseExprPoundCodeCompletion(Optional<StmtKind> ParentKind);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user