summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-08 06:12:54 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-08 06:12:54 +0000
commit5d6790c746d04636d284e47aea2c7cd68bbdf601 (patch)
treee52052e3e02a6665dee151decdc1c729a933e217 /clang
parent443923b72d046d5adbce4e9fd6f20d5e25680389 (diff)
downloadbcm5719-llvm-5d6790c746d04636d284e47aea2c7cd68bbdf601.tar.gz
bcm5719-llvm-5d6790c746d04636d284e47aea2c7cd68bbdf601.zip
Sema: Treat 'strict' availability flag like unavailable
This is a follow-up to r261512, which made the 'strict' availability attribute flag behave like 'unavailable'. However, that fix was insufficient. The following case would (erroneously) error when the deployment target was older than 10.9: struct __attribute__((availability(macosx,strict,introduced=10.9))) A; __attribute__((availability(macosx,strict,introduced=10.9))) void f(A*); The use of A* in the argument list for f is valid here, since f and A have the same availability. The fix is to return AR_Unavailable from DeclBase::getAvailability instead of AR_NotYetIntroduced. This also reverts the special handling added in r261163, instead relying on the well-tested logic for AR_Unavailable. rdar://problem/23791325 llvm-svn: 262915
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/AST/DeclBase.cpp2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp10
-rw-r--r--clang/test/Sema/attr-availability-macosx.c10
3 files changed, 12 insertions, 10 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 27ccb7d5d76..5ec05a6604b 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -432,7 +432,7 @@ static AvailabilityResult CheckAvailability(ASTContext &Context,
<< VTI << HintMessage;
}
- return AR_NotYetIntroduced;
+ return A->getStrict() ? AR_Unavailable : AR_NotYetIntroduced;
}
// Make sure that this declaration hasn't been obsoleted.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4071acd9063..4b8817529e3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -159,19 +159,11 @@ DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
break;
case AR_NotYetIntroduced: {
- // With strict, the compiler will emit unavailable error.
- AvailabilityAttr *AA = D->getAttr<AvailabilityAttr>();
- if (AA && AA->getStrict() &&
- S.getCurContextAvailability() != AR_NotYetIntroduced)
- S.EmitAvailabilityWarning(Sema::AD_Unavailable,
- D, Message, Loc, UnknownObjCClass, ObjCPDecl,
- ObjCPropertyAccess);
-
// Don't do this for enums, they can't be redeclared.
if (isa<EnumConstantDecl>(D) || isa<EnumDecl>(D))
break;
- bool Warn = !AA->isInherited();
+ bool Warn = !D->getAttr<AvailabilityAttr>()->isInherited();
// Objective-C method declarations in categories are not modelled as
// redeclarations, so manually look for a redeclaration in a category
// if necessary.
diff --git a/clang/test/Sema/attr-availability-macosx.c b/clang/test/Sema/attr-availability-macosx.c
index 7efe7506926..21a79ff17a1 100644
--- a/clang/test/Sema/attr-availability-macosx.c
+++ b/clang/test/Sema/attr-availability-macosx.c
@@ -22,6 +22,16 @@ void test() {
f6(0); // expected-error{{'f6' is unavailable: introduced in OS X 10.6}}
}
+struct __attribute__((availability(macosx,strict,introduced=10.6)))
+ not_yet_introduced_struct; // \
+ expected-note{{'not_yet_introduced_struct' has been explicitly marked unavailable here}}
+
+void uses_not_introduced_struct(struct not_yet_introduced_struct *); // \
+ expected-error{{'not_yet_introduced_struct' is unavailable: introduced in OS X 10.6}}
+
+__attribute__((availability(macosx,strict,introduced=10.6)))
+void uses_not_introduced_struct_same_availability(struct not_yet_introduced_struct *);
+
// rdar://10535640
enum {
OpenPOWER on IntegriCloud