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;
[EMAIL PROTECTED](assign, readonly) id N;
[EMAIL PROTECTED](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;
 }
 
[EMAIL PROTECTED](assign,readonly) int p0;
[EMAIL PROTECTED](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;
 }
[EMAIL PROTECTED](readonly, assign) id object;
[EMAIL PROTECTED](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
+
[EMAIL PROTECTED] P0
[EMAIL PROTECTED](readonly,assign) id X; // expected-error {{property 
attributes 'readonly' and 'assign' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P1
[EMAIL PROTECTED](readonly,retain) id X; // expected-error {{property 
attributes 'readonly' and 'retain' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P2
[EMAIL PROTECTED](readonly,copy) id X; // expected-error {{property attributes 
'readonly' and 'copy' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P3
[EMAIL PROTECTED](readonly,readwrite) id X; // expected-error {{property 
attributes 'readonly' and 'readwrite' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P4
[EMAIL PROTECTED](assign,copy) id X; // expected-error {{property attributes 
'assign' and 'copy' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P5
[EMAIL PROTECTED](assign,retain) id X; // expected-error {{property attributes 
'assign' and 'retain' are mutually exclusive}}
[EMAIL PROTECTED]
+
[EMAIL PROTECTED] P6
[EMAIL PROTECTED](copy,retain) id X; // expected-error {{property attributes 
'copy' and 'retain' are mutually exclusive}}
[EMAIL PROTECTED]
+
+
+

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
[EMAIL PROTECTED] (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'}}
[EMAIL PROTECTED] (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


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to