r179108 - Objective-C: This patch fixes a none-issuance of warning

Fariborz Jahanian fjahanian at apple.com
Tue Apr 9 10:52:29 PDT 2013


Author: fjahanian
Date: Tue Apr  9 12:52:29 2013
New Revision: 179108

URL: http://llvm.org/viewvc/llvm-project?rev=179108&view=rev
Log:
Objective-C: This patch fixes a none-issuance of warning
when result type of protocol property and getter method
differ by fixing a more serious problem. When a forward
protocol declaration comes between its definition and
its use in class protocol list, the forward protocol
ast was being used in building the protocol list.
// rdar://12522752

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/method-conflict-2.m

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=179108&r1=179107&r2=179108&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Apr  9 12:52:29 2013
@@ -745,7 +745,10 @@ Sema::FindProtocolDeclaration(bool WarnO
         << ProtocolId[i].first;
       continue;
     }
-
+    // If this is a forward protocol declaration, get its definition.
+    if (!PDecl->isThisDeclarationADefinition() && PDecl->getDefinition())
+      PDecl = PDecl->getDefinition();
+    
     (void)DiagnoseUseOfDecl(PDecl, ProtocolId[i].second);
 
     // If this is a forward declaration and we are supposed to warn in this

Modified: cfe/trunk/test/SemaObjC/method-conflict-2.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-conflict-2.m?rev=179108&r1=179107&r2=179108&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-conflict-2.m (original)
+++ cfe/trunk/test/SemaObjC/method-conflict-2.m Tue Apr  9 12:52:29 2013
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -x objective-c++ -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s
 
 @interface A @end
 @interface B : A @end
@@ -42,3 +43,24 @@
 - (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
 - (id) test2 { return 0; }
 @end
+
+// rdar://12522752
+typedef int int32_t;
+typedef long long int64_t;
+
+ at interface NSObject @end
+
+ at protocol CKMessage
+ at property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}}
+ at end
+
+ at protocol CKMessage;
+
+ at interface CKIMMessage : NSObject<CKMessage>
+ at end
+
+ at implementation CKIMMessage
+- (int32_t)sequenceNumber { // expected-warning {{conflicting return type in implementation of 'sequenceNumber': 'int64_t' (aka 'long long') vs 'int32_t' (aka 'int')}}
+  return 0;
+}
+ at end





More information about the cfe-commits mailing list