@@ -582,10 +582,11 @@ bool Parser::parseSpecializeAttributeArguments(
582582 swift::tok ClosingBrace, bool &DiscardAttribute, Optional<bool > &Exported,
583583 Optional<SpecializeAttr::SpecializationKind> &Kind,
584584 swift::TrailingWhereClause *&TrailingWhereClause,
585- DeclNameRef &targetFunction, SmallVectorImpl<Identifier> &spiGroups,
585+ DeclNameRef &targetFunction, AvailabilityContext *SILAvailability, SmallVectorImpl<Identifier> &spiGroups,
586586 SmallVectorImpl<AvailableAttr *> &availableAttrs,
587587 llvm::function_ref<bool (Parser &)> parseSILTargetName,
588588 llvm::function_ref<bool(Parser &)> parseSILSIPModule) {
589+ bool isSIL = SILAvailability != nullptr ;
589590 SyntaxParsingContext ContentContext (SyntaxContext,
590591 SyntaxKind::SpecializeAttributeSpecList);
591592 // Parse optional "exported" and "kind" labeled parameters.
@@ -601,7 +602,8 @@ bool Parser::parseSpecializeAttributeArguments(
601602 : SyntaxKind::LabeledSpecializeEntry));
602603 if (ParamLabel != " exported" && ParamLabel != " kind" &&
603604 ParamLabel != " target" && ParamLabel != " spi" &&
604- ParamLabel != " spiModule" && ParamLabel != " availability" ) {
605+ ParamLabel != " spiModule" && ParamLabel != " availability" &&
606+ (!isSIL || ParamLabel != " available" )) {
605607 diagnose (Tok.getLoc (), diag::attr_specialize_unknown_parameter_name,
606608 ParamLabel);
607609 }
@@ -627,6 +629,15 @@ bool Parser::parseSpecializeAttributeArguments(
627629 diagnose (Tok.getLoc (), diag::attr_specialize_parameter_already_defined,
628630 ParamLabel);
629631 }
632+ if (ParamLabel == " available" ) {
633+ SourceRange range;
634+ llvm::VersionTuple version;
635+ if (parseVersionTuple (version, range,
636+ diag::sil_availability_expected_version))
637+ return false ;
638+
639+ *SILAvailability = AvailabilityContext (VersionRange::allGTE (version));
640+ }
630641 if (ParamLabel == " availability" ) {
631642 SourceRange attrRange;
632643 auto Loc = Tok.getLoc ();
@@ -877,7 +888,7 @@ bool Parser::parseAvailability(
877888
878889bool Parser::parseSpecializeAttribute (
879890 swift::tok ClosingBrace, SourceLoc AtLoc, SourceLoc Loc,
880- SpecializeAttr *&Attr,
891+ SpecializeAttr *&Attr, AvailabilityContext *SILAvailability,
881892 llvm::function_ref<bool (Parser &)> parseSILTargetName,
882893 llvm::function_ref<bool(Parser &)> parseSILSIPModule) {
883894 assert (ClosingBrace == tok::r_paren || ClosingBrace == tok::r_square);
@@ -896,7 +907,7 @@ bool Parser::parseSpecializeAttribute(
896907 SmallVector<AvailableAttr *, 4 > availableAttrs;
897908 if (!parseSpecializeAttributeArguments (
898909 ClosingBrace, DiscardAttribute, exported, kind, trailingWhereClause,
899- targetFunction, spiGroups, availableAttrs, parseSILTargetName,
910+ targetFunction, SILAvailability, spiGroups, availableAttrs, parseSILTargetName,
900911 parseSILSIPModule)) {
901912 return false ;
902913 }
@@ -2588,7 +2599,7 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
25882599 return false ;
25892600 }
25902601 SpecializeAttr *Attr;
2591- if (!parseSpecializeAttribute (tok::r_paren, AtLoc, Loc, Attr))
2602+ if (!parseSpecializeAttribute (tok::r_paren, AtLoc, Loc, Attr, nullptr ))
25922603 return false ;
25932604
25942605 Attributes.add (Attr);
0 commit comments