Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,19 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,

Opts.Features.insert(*feature);
}

// Hack: In order to support using availability macros in SPM packages, we
// need to be able to use:
// .enableExperimentalFeature("AvailabilityMacro='...'")
// within the package manifest and the feature recognizer can't recognize
// this form of feature, so specially handle it here until features can
// maybe have extra arguments in the future.
auto strRef = StringRef(A->getValue());
if (strRef.startswith("AvailabilityMacro=")) {
auto availability = strRef.split("=").second;

Opts.AvailabilityMacros.push_back(availability.str());
}
}

// Map historical flags over to future features.
Expand Down
9 changes: 9 additions & 0 deletions test/Sema/availability_define.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
// RUN: -define-availability "_macOS11_0:macOS 11.0" \
// RUN: -define-availability "_myProject 1.0:macOS 11.0" \
// RUN: -define-availability "_myProject 2.5:macOS 12.5"

// RUN: %target-typecheck-verify-swift \
// RUN: -enable-experimental-feature AvailabilityMacro='_iOS13Aligned:macOS 10.15, iOS 13.0' \
// RUN: -enable-experimental-feature AvailabilityMacro="_iOS14Aligned:macOS 11.0, iOS 14.0" \
// RUN: -enable-experimental-feature AvailabilityMacro='_iOS14:iOS 14.0' \
// RUN: -enable-experimental-feature AvailabilityMacro="_macOS11_0:macOS 11.0" \
// RUN: -enable-experimental-feature AvailabilityMacro='_myProject 1.0:macOS 11.0' \
// RUN: -enable-experimental-feature AvailabilityMacro="_myProject 2.5:macOS 12.5"

// REQUIRES: OS=macosx

@available(_iOS13Aligned, *)
Expand Down