diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-06 23:47:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-10-06 23:47:58 +0000 |
commit | 7d65f6965d215f4cb2eb0738ee1b9024e5ab5bba (patch) | |
tree | c698f64aa9ab44afb1d267ad8718781d10b1c1d9 | |
parent | 1b41716abf6856af893fd2f13cd0272dffa0e312 (diff) |
objc: Improve on diagnostic when atomic proeprty is synthesized
on one accessor and user-provide with another.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141343 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 6 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 4 | ||||
-rw-r--r-- | test/SemaObjC/atomoic-property-synnthesis-rules.m | 24 |
3 files changed, 23 insertions, 11 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 411d49c912..28e0fab4e3 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -498,9 +498,11 @@ def warn_objc_property_retain_of_block : Warning< "retain'ed block property does not copy the block " "- use copy attribute instead">, InGroup<ObjCRetainBlockProperty>; def warn_atomic_property_rule : Warning< - "writable atomic property %0 cannot pair a synthesized setter/getter " - "with a user defined setter/getter">, + "writable atomic property %0 cannot pair a synthesized %select{getter|setter}1 " + "with a user defined %select{getter|setter}2">, InGroup<DiagGroup<"atomic-property-with-user-defined-accessor">>; +def note_atomic_property_fixup_suggest : Note<"setter and getter must both be " + "synthesized, or both be user defined,or the property must be nonatomic">; def warn_atomic_property_nontrivial_assign_op : Warning< "atomic property of type %0 synthesizing setter using non-trivial assignment" "operator">, InGroup<DiagGroup<"objc-property-atomic-setter-synthesis">>; diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 5a54f57580..13ccf82cf4 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1432,7 +1432,9 @@ Sema::AtomicPropertySetterGetterRules (ObjCImplDecl* IMPDecl, (GetterMethod ? GetterMethod->getLocation() : SetterMethod->getLocation()); Diag(MethodLoc, diag::warn_atomic_property_rule) - << Property->getIdentifier(); + << Property->getIdentifier() << (GetterMethod != 0) + << (SetterMethod != 0); + Diag(MethodLoc, diag::note_atomic_property_fixup_suggest); Diag(Property->getLocation(), diag::note_property_declare); } } diff --git a/test/SemaObjC/atomoic-property-synnthesis-rules.m b/test/SemaObjC/atomoic-property-synnthesis-rules.m index af790e3159..2061a779dc 100644 --- a/test/SemaObjC/atomoic-property-synnthesis-rules.m +++ b/test/SemaObjC/atomoic-property-synnthesis-rules.m @@ -240,8 +240,10 @@ GET(GetSet) SET(GetSet) -GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter/getter with a user defined setter/getter}} -SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized setter/getter with a user defined setter/getter}} +GET(Get) // expected-warning {{writable atomic property 'Get' cannot pair a synthesized setter with a user defined getter}} \ + // expected-note {{setter and getter must both be synthesized}} +SET(Set) // expected-warning {{writable atomic property 'Set' cannot pair a synthesized getter with a user defined setter}} \ + // expected-note {{setter and getter must both be synthesized}} GET(GetSet_Nonatomic) SET(GetSet_Nonatomic) GET(Get_Nonatomic) @@ -258,8 +260,10 @@ SET(Set_Nonatomic_ReadOnly) GET(GetSet_ReadWriteInExt) SET(GetSet_ReadWriteInExt) -GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}} -SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized setter/getter with a user defined setter/getter}} +GET(Get_ReadWriteInExt) // expected-warning {{writable atomic property 'Get_ReadWriteInExt' cannot pair a synthesized setter with a user defined getter}} \ + // expected-note {{setter and getter must both be synthesized}} +SET(Set_ReadWriteInExt) // expected-warning {{writable atomic property 'Set_ReadWriteInExt' cannot pair a synthesized getter with a user defined setter}} \ + // expected-note {{setter and getter must both be synthesized}} GET(GetSet_Nonatomic_ReadWriteInExt) SET(GetSet_Nonatomic_ReadWriteInExt) GET(Get_Nonatomic_ReadWriteInExt) @@ -268,8 +272,10 @@ SET(Set_Nonatomic_ReadWriteInExt) GET(GetSet_LateSynthesize) SET(GetSet_LateSynthesize) -GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}} -SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}} +GET(Get_LateSynthesize) // expected-warning {{writable atomic property 'Get_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \ + // expected-note {{setter and getter must both be synthesized}} +SET(Set_LateSynthesize) // expected-warning {{writable atomic property 'Set_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \ + // expected-note {{setter and getter must both be synthesized}} GET(GetSet_Nonatomic_LateSynthesize) SET(GetSet_Nonatomic_LateSynthesize) GET(Get_Nonatomic_LateSynthesize) @@ -286,8 +292,10 @@ SET(Set_Nonatomic_ReadOnly_LateSynthesize) GET(GetSet_ReadWriteInExt_LateSynthesize) SET(GetSet_ReadWriteInExt_LateSynthesize) -GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}} -SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter/getter with a user defined setter/getter}} +GET(Get_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Get_ReadWriteInExt_LateSynthesize' cannot pair a synthesized setter with a user defined getter}} \ + // expected-note {{setter and getter must both be synthesized}} +SET(Set_ReadWriteInExt_LateSynthesize) // expected-warning {{writable atomic property 'Set_ReadWriteInExt_LateSynthesize' cannot pair a synthesized getter with a user defined setter}} \ + // expected-note {{setter and getter must both be synthesized}} GET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize) SET(GetSet_Nonatomic_ReadWriteInExt_LateSynthesize) GET(Get_Nonatomic_ReadWriteInExt_LateSynthesize) |