@@ -2749,6 +2749,53 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
27492749 Attributes.add (TypeSequenceAttr::create (Context, AtLoc, range));
27502750 break ;
27512751 }
2752+
2753+ case DAK_UnavailableFromAsync: {
2754+ StringRef message;
2755+ if (consumeIf (tok::l_paren)) {
2756+ if (!Tok.is (tok::identifier)) {
2757+ llvm_unreachable (" Flag must start with an indentifier" );
2758+ }
2759+
2760+ StringRef flag = Tok.getText ();
2761+
2762+ if (flag != " message" ) {
2763+ diagnose (Tok.getLoc (), diag::attr_unknown_option, flag, AttrName);
2764+ return true ;
2765+ }
2766+ consumeToken ();
2767+ if (!consumeIf (tok::colon)) {
2768+ if (!Tok.is (tok::equal)) {
2769+ diagnose (Tok.getLoc (), diag::attr_expected_colon_after_label, flag);
2770+ return false ;
2771+ }
2772+ diagnose (Tok.getLoc (), diag::replace_equal_with_colon_for_value)
2773+ .fixItReplace (Tok.getLoc (), " : " );
2774+ consumeToken ();
2775+ }
2776+ if (!Tok.is (tok::string_literal)) {
2777+ diagnose (Tok.getLoc (), diag::attr_expected_string_literal, AttrName);
2778+ return false ;
2779+ }
2780+
2781+ Optional<StringRef> value = getStringLiteralIfNotInterpolated (
2782+ Tok.getLoc (), flag);
2783+ if (!value)
2784+ return false ;
2785+ Token stringTok = Tok;
2786+ consumeToken ();
2787+ message = *value;
2788+
2789+ if (!consumeIf (tok::r_paren))
2790+ diagnose (stringTok.getRange ().getEnd (), diag::attr_expected_rparen,
2791+ AttrName, /* isModifiler*/ false )
2792+ .fixItInsertAfter (stringTok.getLoc (), " )" );
2793+ }
2794+
2795+ Attributes.add (new (Context) UnavailableFromAsyncAttr (
2796+ message, AtLoc, SourceRange (Loc, Tok.getLoc ()), false ));
2797+ break ;
2798+ }
27522799 }
27532800
27542801 if (DuplicateAttribute) {
0 commit comments