@@ -1289,9 +1289,8 @@ static void parseGuardedPattern(Parser &P, GuardedPattern &result,
12891289// / removing specs for unrecognized platforms.
12901290static void
12911291validateAvailabilitySpecList (Parser &P,
1292- SmallVectorImpl<AvailabilitySpec *> &Specs,
1292+ const SmallVectorImpl<AvailabilitySpec *> &Specs,
12931293 Parser::AvailabilitySpecSource Source) {
1294- llvm::SmallSet<PlatformKind, 4 > Platforms;
12951294 std::optional<SourceLoc> WildcardSpecLoc = std::nullopt ;
12961295
12971296 if (Specs.size () == 1 ) {
@@ -1303,37 +1302,9 @@ validateAvailabilitySpecList(Parser &P,
13031302 return ;
13041303 }
13051304
1306- SmallVector<AvailabilitySpec *, 5 > RecognizedSpecs;
13071305 for (auto *Spec : Specs) {
1308- RecognizedSpecs.push_back (Spec);
13091306 if (Spec->isWildcard ()) {
13101307 WildcardSpecLoc = Spec->getStartLoc ();
1311- continue ;
1312- }
1313-
1314- // We keep specs for unrecognized domains around for error recovery
1315- // during parsing but remove them once parsing is completed.
1316- auto Domain = Spec->getDomain ();
1317- if (!Domain) {
1318- RecognizedSpecs.pop_back ();
1319- continue ;
1320- }
1321-
1322- if (!Domain->isPlatform ()) {
1323- P.diagnose (Spec->getStartLoc (), diag::availability_must_occur_alone,
1324- Domain->getNameForAttributePrinting ());
1325- continue ;
1326- }
1327-
1328- bool Inserted = Platforms.insert (Spec->getPlatform ()).second ;
1329- if (!Inserted) {
1330- // Rule out multiple version specs referring to the same platform.
1331- // For example, we emit an error for
1332- // / #available(OSX 10.10, OSX 10.11, *)
1333- PlatformKind Platform = Spec->getPlatform ();
1334- P.diagnose (Spec->getStartLoc (),
1335- diag::availability_query_repeated_platform,
1336- platformString (Platform));
13371308 }
13381309 }
13391310
@@ -1362,8 +1333,6 @@ validateAvailabilitySpecList(Parser &P,
13621333 break ;
13631334 }
13641335 }
1365-
1366- Specs = RecognizedSpecs;
13671336}
13681337
13691338// #available(...)
@@ -1398,18 +1367,6 @@ ParserResult<PoundAvailableInfo> Parser::parseStmtConditionPoundAvailable() {
13981367 SmallVector<AvailabilitySpec *, 5 > Specs;
13991368 ParserStatus Status = parseAvailabilitySpecList (Specs, Source);
14001369
1401- for (auto *Spec : Specs) {
1402- if (Spec->getPlatform () != PlatformKind::none || Spec->isWildcard ())
1403- continue ;
1404-
1405- diagnose (Spec->getStartLoc (),
1406- Spec->getDomain ()->isSwiftLanguage ()
1407- ? diag::pound_available_swift_not_allowed
1408- : diag::pound_available_package_description_not_allowed,
1409- getTokenText (MainToken));
1410- Status.setIsParseError ();
1411- }
1412-
14131370 SourceLoc RParenLoc;
14141371 if (parseMatchingToken (tok::r_paren, RParenLoc,
14151372 diag::avail_query_expected_rparen, LParenLoc))
0 commit comments