From 3c9a0240b6db6ee02a24f48c753089bda48843ae Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 9 Apr 2013 17:52:29 +0000 Subject: [PATCH] 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179108 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclObjC.cpp | 5 ++++- test/SemaObjC/method-conflict-2.m | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 5c26d7ff8e..cb5de9c84a 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -745,7 +745,10 @@ Sema::FindProtocolDeclaration(bool WarnOnDeclarations, << 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 diff --git a/test/SemaObjC/method-conflict-2.m b/test/SemaObjC/method-conflict-2.m index df59f242ce..ec80a433cc 100644 --- a/test/SemaObjC/method-conflict-2.m +++ b/test/SemaObjC/method-conflict-2.m @@ -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; + +@interface NSObject @end + +@protocol CKMessage +@property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}} +@end + +@protocol CKMessage; + +@interface CKIMMessage : NSObject +@end + +@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; +} +@end -- 2.40.0