r262915 - Sema: Treat 'strict' availability flag like unavailable
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 22:12:54 PST 2016
Author: dexonsmith
Date: Tue Mar 8 00:12:54 2016
New Revision: 262915
URL: http://llvm.org/viewvc/llvm-project?rev=262915&view=rev
Log:
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
Modified:
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/attr-availability-macosx.c
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=262915&r1=262914&r2=262915&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Mar 8 00:12:54 2016
@@ -432,7 +432,7 @@ static AvailabilityResult CheckAvailabil
<< VTI << HintMessage;
}
- return AR_NotYetIntroduced;
+ return A->getStrict() ? AR_Unavailable : AR_NotYetIntroduced;
}
// Make sure that this declaration hasn't been obsoleted.
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=262915&r1=262914&r2=262915&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Mar 8 00:12:54 2016
@@ -159,19 +159,11 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
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.
Modified: cfe/trunk/test/Sema/attr-availability-macosx.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-availability-macosx.c?rev=262915&r1=262914&r2=262915&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-availability-macosx.c (original)
+++ cfe/trunk/test/Sema/attr-availability-macosx.c Tue Mar 8 00:12:54 2016
@@ -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 {
More information about the cfe-commits
mailing list