Author: arphaman Date: Fri Feb 23 15:49:43 2018 New Revision: 325994 URL: http://llvm.org/viewvc/llvm-project?rev=325994&view=rev Log: [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 Added: cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=325994&r1=325993&r2=325994&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Feb 23 15:49:43 2018 @@ -1835,6 +1835,13 @@ ActOnStartCategoryInterface(SourceLocati // 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(SourceLocati NumProtoRefs, Context); } - if (AttrList) - ProcessDeclAttributeList(TUScope, CDecl, AttrList); - AddPragmaAttributes(TUScope, CDecl); - CheckObjCDeclScope(CDecl); return ActOnObjCContainerStartDefinition(CDecl); } Added: cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m?rev=325994&view=auto ============================================================================== --- cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m (added) +++ cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m Fri Feb 23 15:49:43 2018 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits