From: Ted Kremenek Date: Thu, 12 Dec 2013 23:40:14 +0000 (+0000) Subject: Enhance "auto synthesis will not synthesize property in protocol" to include property... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5184f04d3cc445340846840042e2dc7756a509fe;p=clang Enhance "auto synthesis will not synthesize property in protocol" to include property and protocol name. Implements . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197187 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 741d4c6e27..b0deed75ec 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -701,8 +701,8 @@ def warn_owning_getter_rule : Warning< " convention for returning 'owned' objects">, InGroup>; def warn_auto_synthesizing_protocol_property :Warning< - "auto property synthesis will not synthesize property" - " declared in a protocol">, + "auto property synthesis will not synthesize property %0" + " declared in protocol %1">, InGroup>; def warn_no_autosynthesis_shared_ivar_property : Warning < "auto property synthesis will not synthesize property " diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index f70e84d7a0..78e774b39f 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1574,10 +1574,12 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, } continue; } - if (isa(Prop->getDeclContext())) { + if (ObjCProtocolDecl *Proto = + dyn_cast(Prop->getDeclContext())) { // We won't auto-synthesize properties declared in protocols. Diag(IMPDecl->getLocation(), - diag::warn_auto_synthesizing_protocol_property); + diag::warn_auto_synthesizing_protocol_property) + << Prop << Proto; Diag(Prop->getLocation(), diag::note_property_declare); continue; } diff --git a/test/SemaObjC/default-synthesize-3.m b/test/SemaObjC/default-synthesize-3.m index 0275806dd0..e409d21692 100644 --- a/test/SemaObjC/default-synthesize-3.m +++ b/test/SemaObjC/default-synthesize-3.m @@ -172,12 +172,12 @@ typedef NSObject FooObject; @interface Okay : NSObject @end -@implementation Okay // expected-warning 2 {{auto property synthesis will not synthesize property declared in a protocol}} +@implementation Okay // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}} @end @interface Fail : FooObject @end -@implementation Fail // expected-warning 2 {{auto property synthesis will not synthesize property declared in a protocol}} +@implementation Fail // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}} @end diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m index dd16c1361d..9356b9f5b3 100644 --- a/test/SemaObjC/default-synthesize.m +++ b/test/SemaObjC/default-synthesize.m @@ -136,5 +136,5 @@ @interface MyClass @end -@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}} +@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}} @end diff --git a/test/SemaObjC/forward-protocol-incomplete-impl-warn.m b/test/SemaObjC/forward-protocol-incomplete-impl-warn.m index c3efeba4f9..654ef59f3d 100644 --- a/test/SemaObjC/forward-protocol-incomplete-impl-warn.m +++ b/test/SemaObjC/forward-protocol-incomplete-impl-warn.m @@ -15,6 +15,6 @@ @interface IBImageCatalogDocument : NSObject // expected-note {{required for direct or indirect protocol 'DVTInvalidation'}} @end -@implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}} \ +@implementation IBImageCatalogDocument // expected-warning {{auto property synthesis will not synthesize property 'Prop' declared in protocol 'DVTInvalidation'}} \ // expected-warning {{method 'invalidate' in protocol not implemented}} @end