diff options
| author | Alex Lorenz <arphaman@gmail.com> | 2018-02-23 23:49:43 +0000 |
|---|---|---|
| committer | Alex Lorenz <arphaman@gmail.com> | 2018-02-23 23:49:43 +0000 |
| commit | a9c966d0a946fd36bc4421791f6dbc440b65a1aa (patch) | |
| tree | d35b42456a9564c414837cd8b6607eda0bdb7d3f | |
| parent | b68cef9dd0e204bbd4fa17f2559416d5b44829a2 (diff) | |
| download | bcm5719-llvm-a9c966d0a946fd36bc4421791f6dbc440b65a1aa.tar.gz bcm5719-llvm-a9c966d0a946fd36bc4421791f6dbc440b65a1aa.zip | |
[Sema][ObjC] Process category attributes before checking protocol uses
This ensures that any availability attributes are attached to the
category before the availability for the referenced protocols is checked.
rdar://37829755
llvm-svn: 325994
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 11 | ||||
| -rw-r--r-- | clang/test/SemaObjC/unguarded-availability-category-protocol-use.m | 18 |
2 files changed, 25 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index c17fde497ae..cab6a50629d 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1835,6 +1835,13 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, // FIXME: PushOnScopeChains? CurContext->addDecl(CDecl); + // Process the attributes before looking at protocols to ensure that the + // availability attribute is attached to the category to provide availability + // checking for protocol uses. + if (AttrList) + ProcessDeclAttributeList(TUScope, CDecl, AttrList); + AddPragmaAttributes(TUScope, CDecl); + if (NumProtoRefs) { diagnoseUseOfProtocols(*this, CDecl, (ObjCProtocolDecl*const*)ProtoRefs, NumProtoRefs, ProtoLocs); @@ -1846,10 +1853,6 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, NumProtoRefs, Context); } - if (AttrList) - ProcessDeclAttributeList(TUScope, CDecl, AttrList); - AddPragmaAttributes(TUScope, CDecl); - CheckObjCDeclScope(CDecl); return ActOnObjCContainerStartDefinition(CDecl); } diff --git a/clang/test/SemaObjC/unguarded-availability-category-protocol-use.m b/clang/test/SemaObjC/unguarded-availability-category-protocol-use.m new file mode 100644 index 00000000000..d2eb9f4841b --- /dev/null +++ b/clang/test/SemaObjC/unguarded-availability-category-protocol-use.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple arm64-apple-ios10 -Wunguarded-availability -fblocks -fsyntax-only -verify %s + +__attribute__((availability(ios,unavailable))) +@protocol Prot // expected-note {{here}} + +@end + +@interface A +@end + +__attribute__((availability(ios,unavailable))) +@interface A (Cat) <Prot> // No error. +@end + +__attribute__((availability(tvos,unavailable))) +@interface B @end +@interface B (Cat) <Prot> // expected-error {{'Prot' is unavailable: not available on iOS}} +@end |

