diff options
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 18 | ||||
| -rw-r--r-- | clang/test/Analysis/PR2978.m | 2 | ||||
| -rw-r--r-- | clang/test/Coverage/objc-language-features.inc | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/continuation-class-err.m | 2 | ||||
| -rw-r--r-- | clang/test/SemaObjC/property-12.m | 32 | ||||
| -rw-r--r-- | clang/test/SemaObjC/property-3.m | 2 | 
6 files changed, 50 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 03c803054ca..19769b82e35 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1229,12 +1229,22 @@ void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,                                         unsigned &Attributes) {    // FIXME: Improve the reported location. -  // readonly and readwrite conflict. +  // readonly and readwrite/assign/retain/copy conflict.    if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) && -      (Attributes & ObjCDeclSpec::DQ_PR_readwrite)) { +      (Attributes & (ObjCDeclSpec::DQ_PR_readwrite | +                     ObjCDeclSpec::DQ_PR_assign | +                     ObjCDeclSpec::DQ_PR_copy | +                     ObjCDeclSpec::DQ_PR_retain))) { +    const char * which = (Attributes & ObjCDeclSpec::DQ_PR_readwrite) ? +                          "readwrite" : +                         (Attributes & ObjCDeclSpec::DQ_PR_assign) ? +                          "assign" : +                         (Attributes & ObjCDeclSpec::DQ_PR_copy) ? +                          "copy" : "retain"; +                               Diag(Loc, diag::err_objc_property_attr_mutually_exclusive) -      << "readonly" << "readwrite"; -    Attributes &= ~ObjCDeclSpec::DQ_PR_readonly; +      << "readonly" << which; +    return;    }    // Check for copy or retain on non-object types. diff --git a/clang/test/Analysis/PR2978.m b/clang/test/Analysis/PR2978.m index aa5d173807b..0b9ae233786 100644 --- a/clang/test/Analysis/PR2978.m +++ b/clang/test/Analysis/PR2978.m @@ -23,7 +23,7 @@  @property(retain) id Y;  @property(assign) id Z;  @property(assign) id K; -@property(assign, readonly) id N; +@property(readonly) id N;  @property(retain) id M;  @property(retain) id V;  @property(retain) id W; diff --git a/clang/test/Coverage/objc-language-features.inc b/clang/test/Coverage/objc-language-features.inc index 793d0e5a442..25988f5e53a 100644 --- a/clang/test/Coverage/objc-language-features.inc +++ b/clang/test/Coverage/objc-language-features.inc @@ -16,7 +16,7 @@    B *iv1;  } -@property(assign,readonly) int p0; +@property(readonly) int p0;  @property(assign,nonatomic,readwrite) int p1;  @property(copy) id p2;  @property(retain) id p3; diff --git a/clang/test/SemaObjC/continuation-class-err.m b/clang/test/SemaObjC/continuation-class-err.m index 321615ece31..1ddbd623652 100644 --- a/clang/test/SemaObjC/continuation-class-err.m +++ b/clang/test/SemaObjC/continuation-class-err.m @@ -5,7 +5,7 @@    id _object;    id _object1;  } -@property(readonly, assign) id object; +@property(readonly) id object;  @property(readwrite, assign) id object1;  @end diff --git a/clang/test/SemaObjC/property-12.m b/clang/test/SemaObjC/property-12.m new file mode 100644 index 00000000000..bdd026d32fc --- /dev/null +++ b/clang/test/SemaObjC/property-12.m @@ -0,0 +1,32 @@ +// RUN: clang -fsyntax-only -verify %s + +@protocol P0 +@property(readonly,assign) id X; // expected-error {{property attributes 'readonly' and 'assign' are mutually exclusive}} +@end + +@protocol P1 +@property(readonly,retain) id X; // expected-error {{property attributes 'readonly' and 'retain' are mutually exclusive}} +@end + +@protocol P2 +@property(readonly,copy) id X; // expected-error {{property attributes 'readonly' and 'copy' are mutually exclusive}} +@end + +@protocol P3 +@property(readonly,readwrite) id X; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}} +@end + +@protocol P4 +@property(assign,copy) id X; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}} +@end + +@protocol P5 +@property(assign,retain) id X; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}} +@end + +@protocol P6 +@property(copy,retain) id X; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}} +@end + + + diff --git a/clang/test/SemaObjC/property-3.m b/clang/test/SemaObjC/property-3.m index ed1d1bd2443..ead61508d5a 100644 --- a/clang/test/SemaObjC/property-3.m +++ b/clang/test/SemaObjC/property-3.m @@ -9,6 +9,6 @@  @end  @interface NOW : I -@property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from 'I'}} +@property (readonly) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from 'I'}}  @property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}}  @end  | 

