From: Chris Lattner Date: Sun, 12 Apr 2009 08:43:13 +0000 (+0000) Subject: Fix rdar://6771034: don't warn on use of forward declared protocol in protocol X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58fe03bc8083b92b606c31431feb361c45266cc2;p=clang Fix rdar://6771034: don't warn on use of forward declared protocol in protocol list of another protocol definition. This warning is very noisy and GCC doesn't produce it so existing code doesn't expect it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68894 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 239d35f806..b4f417a15d 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -982,7 +982,7 @@ Parser::DeclPtrTy Parser::ParseObjCAtProtocolDeclaration(SourceLocation AtLoc, llvm::SmallVector ProtocolRefs; if (Tok.is(tok::less) && - ParseObjCProtocolReferences(ProtocolRefs, true, EndProtoLoc)) + ParseObjCProtocolReferences(ProtocolRefs, false, EndProtoLoc)) return DeclPtrTy(); DeclPtrTy ProtoType = diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 90a6bee819..49433b5b7b 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -503,7 +503,7 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, } } -/// ActOnForwardProtocolDeclaration - +/// ActOnForwardProtocolDeclaration - Handle @protocol foo; Action::DeclPtrTy Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, const IdentifierLocPair *IdentList, diff --git a/test/Analysis/region-1.m b/test/Analysis/region-1.m index f9905079eb..ed172e431e 100644 --- a/test/Analysis/region-1.m +++ b/test/Analysis/region-1.m @@ -19,14 +19,14 @@ typedef unsigned int NSUInteger; @end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView; @class JabasectItem; @protocol EcoClassifier; -@protocol EcoClassInterfaceCommons @end @protocol EcoImplementation; // expected-warning{{cannot find protocol}} +@protocol EcoClassInterfaceCommons @end @protocol EcoImplementation; @protocol EcoBehavioredClassifier - (NSArray *) implementations; @end enum { CK_UNRESTRICTED= 0, CK_READ_ONLY, CK_ADD_ONLY, CK_REMOVE_ONLY }; @protocol EcoClass - (NSArray *) ownedAttributes; @end @protocol EcoNamespace; @protocol EcoType; -@protocol EcoClassifier - (NSArray *) features; // expected-warning 2 {{cannot find protocol}} +@protocol EcoClassifier - (NSArray *) features; @end @protocol EcoComment; @protocol EcoElement - (NSArray *) ownedElements; @end @protocol EcoDirectedRelationship; diff --git a/test/SemaObjC/method-conflict.m b/test/SemaObjC/method-conflict.m index 957cde3c26..1524fbae56 100644 --- a/test/SemaObjC/method-conflict.m +++ b/test/SemaObjC/method-conflict.m @@ -25,7 +25,7 @@ typedef struct _NSRange { } CSSM_FIELDGROUP, *CSSM_FIELDGROUP_PTR; @protocol XDUMLClassifier; -@protocol XDUMLClassInterfaceCommons // expected-warning {{cannot find protocol definition for 'XDUMLClassifier'}} +@protocol XDUMLClassInterfaceCommons @end @protocol XDUMLImplementation; @protocol XDUMLElement - (NSArray *) ownedElements; @end @protocol XDUMLDataType; diff --git a/test/SemaObjC/protocol-forward-circular.m b/test/SemaObjC/protocol-forward-circular.m index 40da96e096..804c44f6bf 100644 --- a/test/SemaObjC/protocol-forward-circular.m +++ b/test/SemaObjC/protocol-forward-circular.m @@ -1,7 +1,7 @@ // RUN: clang-cc -fsyntax-only -verify %s @protocol B; -@protocol C < B > // expected-warning{{cannot find protocol definition for 'B'}} // expected-note{{previous definition is here}} +@protocol C < B > // expected-note{{previous definition is here}} @end @protocol A < C > @end diff --git a/test/SemaObjC/protocol-test-2.m b/test/SemaObjC/protocol-test-2.m index 3abb9b5935..265e5d2691 100644 --- a/test/SemaObjC/protocol-test-2.m +++ b/test/SemaObjC/protocol-test-2.m @@ -10,7 +10,7 @@ - (INTF1*) meth; @end -@protocol PROTO2 // expected-warning {{cannot find protocol definition for 'p1'}} +@protocol PROTO2 @end @protocol p1 @end @@ -27,5 +27,12 @@ @protocol p2 @end -@protocol PROTO4 // expected-warning {{cannot find protocol definition for 'p3'}} +@protocol PROTO4 +@end + + +// rdar://6771034 +@protocol XX; +@protocol YY // Use of declaration of XX here should not cause a warning. +- zz; @end diff --git a/test/SemaObjC/protocol-undef.m b/test/SemaObjC/protocol-undef.m index 34a33c72f8..6f3350c9e3 100644 --- a/test/SemaObjC/protocol-undef.m +++ b/test/SemaObjC/protocol-undef.m @@ -21,8 +21,8 @@ typedef NSObject OzzyAnchor; - (BOOL)anchor:(OzzyAnchor *)anchor confirmRepresentedObject:(id)newObject; @end typedef NSObject OzzyAnchorDelegate; -// GCC doesn't warn about the following (which is inconsistent with it's handling of @interface below). -@protocol OzzyAnchorP // expected-warning{{cannot find protocol definition for 'OzzyP'}} + +@protocol OzzyAnchorP @property(nonatomic,retain) id representedObject; @property(nonatomic,retain) Ozzy * contentGroup; @end