[cfe-commits] r60620 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/Analysis/PR2978.m test/Coverage/objc-language-features.inc test/SemaObjC/continuation-class-err.m test/SemaObjC/property-12.m test/SemaObjC/property-3.m
Fariborz Jahanian
fjahanian at apple.com
Fri Dec 5 17:12:44 PST 2008
Author: fjahanian
Date: Fri Dec 5 19:12:43 2008
New Revision: 60620
URL: http://llvm.org/viewvc/llvm-project?rev=60620&view=rev
Log:
Patch to diagnose a variety of misuse of property
attributes. Example would be, readonly, assign or
assign, copy, etc.
Added:
cfe/trunk/test/SemaObjC/property-12.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Analysis/PR2978.m
cfe/trunk/test/Coverage/objc-language-features.inc
cfe/trunk/test/SemaObjC/continuation-class-err.m
cfe/trunk/test/SemaObjC/property-3.m
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=60620&r1=60619&r2=60620&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Dec 5 19:12:43 2008
@@ -1229,12 +1229,22 @@
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.
Modified: cfe/trunk/test/Analysis/PR2978.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR2978.m?rev=60620&r1=60619&r2=60620&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/PR2978.m (original)
+++ cfe/trunk/test/Analysis/PR2978.m Fri Dec 5 19:12:43 2008
@@ -23,7 +23,7 @@
@property(retain) id Y;
@property(assign) id Z;
@property(assign) id K;
- at property(assign, readonly) id N;
+ at property(readonly) id N;
@property(retain) id M;
@property(retain) id V;
@property(retain) id W;
Modified: cfe/trunk/test/Coverage/objc-language-features.inc
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/objc-language-features.inc?rev=60620&r1=60619&r2=60620&view=diff
==============================================================================
--- cfe/trunk/test/Coverage/objc-language-features.inc (original)
+++ cfe/trunk/test/Coverage/objc-language-features.inc Fri Dec 5 19:12:43 2008
@@ -16,7 +16,7 @@
B *iv1;
}
- at property(assign,readonly) int p0;
+ at property(readonly) int p0;
@property(assign,nonatomic,readwrite) int p1;
@property(copy) id p2;
@property(retain) id p3;
Modified: cfe/trunk/test/SemaObjC/continuation-class-err.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/continuation-class-err.m?rev=60620&r1=60619&r2=60620&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/continuation-class-err.m (original)
+++ cfe/trunk/test/SemaObjC/continuation-class-err.m Fri Dec 5 19:12:43 2008
@@ -5,7 +5,7 @@
id _object;
id _object1;
}
- at property(readonly, assign) id object;
+ at property(readonly) id object;
@property(readwrite, assign) id object1;
@end
Added: cfe/trunk/test/SemaObjC/property-12.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-12.m?rev=60620&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/property-12.m (added)
+++ cfe/trunk/test/SemaObjC/property-12.m Fri Dec 5 19:12:43 2008
@@ -0,0 +1,32 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at protocol P0
+ at property(readonly,assign) id X; // expected-error {{property attributes 'readonly' and 'assign' are mutually exclusive}}
+ at end
+
+ at protocol P1
+ at property(readonly,retain) id X; // expected-error {{property attributes 'readonly' and 'retain' are mutually exclusive}}
+ at end
+
+ at protocol P2
+ at property(readonly,copy) id X; // expected-error {{property attributes 'readonly' and 'copy' are mutually exclusive}}
+ at end
+
+ at protocol P3
+ at property(readonly,readwrite) id X; // expected-error {{property attributes 'readonly' and 'readwrite' are mutually exclusive}}
+ at end
+
+ at protocol P4
+ at property(assign,copy) id X; // expected-error {{property attributes 'assign' and 'copy' are mutually exclusive}}
+ at end
+
+ at protocol P5
+ at property(assign,retain) id X; // expected-error {{property attributes 'assign' and 'retain' are mutually exclusive}}
+ at end
+
+ at protocol P6
+ at property(copy,retain) id X; // expected-error {{property attributes 'copy' and 'retain' are mutually exclusive}}
+ at end
+
+
+
Modified: cfe/trunk/test/SemaObjC/property-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-3.m?rev=60620&r1=60619&r2=60620&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-3.m (original)
+++ cfe/trunk/test/SemaObjC/property-3.m Fri Dec 5 19:12:43 2008
@@ -9,6 +9,6 @@
@end
@interface NOW : I
- at 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'}}
+ at 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
More information about the cfe-commits
mailing list