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
26 changes: 15 additions & 11 deletions clang/lib/AST/DeclBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,27 +695,31 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
if (!A->getIntroduced().empty() &&
EnclosingVersion < A->getIntroduced()) {
IdentifierInfo *IIEnv = A->getEnvironment();
StringRef TargetEnv =
Context.getTargetInfo().getTriple().getEnvironmentName();
StringRef EnvName = llvm::Triple::getEnvironmentTypeName(
Context.getTargetInfo().getTriple().getEnvironment());
// Matching environment or no environment on attribute
if (!IIEnv || (!TargetEnv.empty() && IIEnv->getName() == TargetEnv)) {
auto &Triple = Context.getTargetInfo().getTriple();
StringRef TargetEnv = Triple.getEnvironmentName();
StringRef EnvName =
llvm::Triple::getEnvironmentTypeName(Triple.getEnvironment());
// Matching environment or no environment on attribute.
if (!IIEnv || (Triple.hasEnvironment() && IIEnv->getName() == TargetEnv)) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
VersionTuple VTI(A->getIntroduced());
Out << "introduced in " << PrettyPlatformName << " " << VTI << " "
<< EnvName << HintMessage;
Out << "introduced in " << PrettyPlatformName << " " << VTI;
if (Triple.hasEnvironment())
Out << " " << EnvName;
Out << HintMessage;
}
}
// Non-matching environment or no environment on target
// Non-matching environment or no environment on target.
else {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
Out << "not available on " << PrettyPlatformName << " " << EnvName
<< HintMessage;
Out << "not available on " << PrettyPlatformName;
if (Triple.hasEnvironment())
Out << " " << EnvName;
Out << HintMessage;
}
}

Expand Down
10 changes: 10 additions & 0 deletions clang/test/Driver/attr-availability-erroneous-diags.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: not %clang -target x86_64-apple-darwin9 -fsyntax-only %s 2>&1 | FileCheck %s

// CHECK: error:
// CHECK-SAME: 'f0' is unavailable: introduced in macOS 11
// CHECK-NOT: unknown

void f0(void) __attribute__((availability(macosx,strict,introduced=11)));

void client(void) {
f0(); }
Loading